You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As it is of my understanding, ApolloServer 2.0 way of integrating an existing server to it is using the applyMiddleware method. I'm wondering why not having something to extract the sub-application (such as a express's Router) instead of doing this highly side-effect based approach of connecting directly to an existing app.
The approach of an exposed sub-application would highly reduce the amount of configuration and assumptions now taken by the current implementation of the apollo-server-express version of the applyMiddleware. For instance:
path: can be completely dropped;
cors: should be handled by the upper application, not ApolloServer;
bodyParserConfig: same as above;
disableHealthCheck: health check logic should be exposed separately, not polluting the upper app;
onHealthCheck: same as above.
My idea is it should be possible for me to do something like this:
./graphql.js
const{ ApolloServer, gql }=require('apollo-server-express')consttypeDefs=gql`...`constresolvers={ ... }constapolloServer=newApolloServer({ typeDefs, resolvers })module.exports=apolloServer.middleware()// or `.app()` or `.router()`
./server.js
constexpress=require('express')constgraphql=require('./graphql')express().use('/graphql',graphql).listen(3000,()=>console.log(`> Ready on http://localhost:3000`))
This way I can invert the order of knowledge, making the graphql logic completely unaware of the application from above.
The text was updated successfully, but these errors were encountered:
I've noticed there are a lot of similar requests coming in for the missing middleware in v2. I'm wondering if we should consolidate them in one issue and close the others.
As it is of my understanding, ApolloServer 2.0 way of integrating an existing server to it is using the
applyMiddleware
method. I'm wondering why not having something to extract the sub-application (such as aexpress
'sRouter
) instead of doing this highly side-effect based approach of connecting directly to an existing app.The approach of an exposed sub-application would highly reduce the amount of configuration and assumptions now taken by the current implementation of the
apollo-server-express
version of theapplyMiddleware
. For instance:path
: can be completely dropped;cors
: should be handled by the upper application, not ApolloServer;bodyParserConfig
: same as above;disableHealthCheck
: health check logic should be exposed separately, not polluting the upper app;onHealthCheck
: same as above.My idea is it should be possible for me to do something like this:
./graphql.js
./server.js
This way I can invert the order of knowledge, making the graphql logic completely unaware of the application from above.
The text was updated successfully, but these errors were encountered: