Open marshall007 opened 5 years ago
Related to #1074 in that Voyager is probably closer to what you'd want to expose to end-users instead of the entire GraphiQL console.
I definitely don't want to bundle more stuff inside PostGraphile; however I've planned to write a voyager server plugin for quite a while just haven't got around to it. To do so, you should only need to implement one hook, against this:
Something like:
const { express: makeVoyagerMiddleware } = require('graphql-voyager/middleware');
let voyagerMiddleware;
module.exports = {
// Use this hook for access to the options, so we know where the GraphQL endpoint is:
'postgraphile:options': (options) => {
voyagerMiddleware = makeVoyagerMiddleware({
endpointUrl: `${options.externalUrlBase || ''}/${options.graphqlRoute}`,
displayOptions: {
hideRoot: true,
skipDeprecated: true,
skipRelay: true,
},
});
return options;
},
// Use this hook to pass over to the voyager middleware if the request matches
'postgraphile:http:handler': (incomingReq, { options, res, next }) => {
if (!incomingReq.match(/^\/voyager(\?|$)/)) return incomingReq;
middleware(incomingReq, res, next);
return null;
}
};
This was written direct into GitHub editor, so it's probably going to need some fixes.
I'm submitting a ...
It is fairly trivial to expose
graphql-voyager
yourself if you are already consumingpostgraphile
as a library. Doing so is roughly as easy as:It would be nice to have Voyager bundled for a couple reasons, namely:
/graphiql
endpoint