Closed lorensr closed 5 years ago
Thanks for the push on this! Hopefully it should happen in the next week or so
Actually, it looks like ApolloServer already works with express-graphql-query-rewriter
using the middleware pattern described in the apollo docs. For example:
const { ApolloServer, gql } = require("apollo-server-express");
const express = require("express");
const { graphqlRewriterMiddleware } = require("express-graphql-query-rewriter");
const server = new ApolloServer({ typeDefs, resolvers });
const app = express();
const path = "/graphql";
app.use(
path,
graphqlRewriterMiddleware({
rewriters: [
// rewriters here as usual
]
})
);
server.applyMiddleware({ app, path, bodyParserConfig: false });
app.listen({ port: 4000 }, () => {
console.log(`🚀 Server ready at http://localhost:4000${server.graphqlPath}`);
});
It seems like the tricky part is passing bodyParserConfig: false
, since express-graphql-query-rewriter
already parses the body of the request in order to do the rewriting.
I updated the README with instructions for apollo-server, so closing this issue for now
I see in the README that this is planned—just opening this issue to track it ☺️