I'm just wondering what's the reason for this seemingly awkward configuration (from Getting Started w/ Apollo Server),
const server = new ApolloServer({
// These will be defined for both new or existing servers
typeDefs,
resolvers,
});
server.applyMiddleware({ app }); // app is from an existing express app
Why is that I'm calling .applyMiddleware()
and feeding it my app
rather than using app.use()
, it even seems from the docs that Apollo is only answering requests on /graphql
wouldn't it be better to follow the Express API of,
let apollo = require('apollo-server').ApolloMiddleware
app.use( '/graphql', apollo({ typeDefs, resolvers }) );
It seems like Apollo is inverting the normal middleware flow of Express? What is the advantage of doing it the Apollo way?