When a GraphQL request arrives at GraphQL Modules, GraphQL Modules creates a scope only for that network request. GraphQL Modules identifies this scope by a unique object given in the global application context. The global application context defined in your GraphQL server/library is not the same with the module's context, because all resolvers, context builders, dependency injections, etc. are encapsulated in the global application context.
You can decide how to pass the session object in your application's context-building phase.
GraphQL Modules tries to get the
session property of your global application context first, but if there is no
session property, it takes all application context objects as your network session objects.
express.Request by default as the global application context:
If we need more stuff in the network session:
On the other hand,
apollo-server needs to be passed it like below:
Even if you want to use
GraphQLModule in a non-GraphQL-Modules application, you can safely pass the context builder of
And you can use the internal context of your
GraphQLModule including Dependency Injection.
GraphQL Modules internally handles
session without the need of passing
You can safely extract reusable
context from your
GraphQLModule, and use it outside
This is what
Session means in GraphQL Modules.
You can read more about Provider Scopes in the Dependency Injection section.