In GraphQL, a
context is an object shared by all the resolvers of a specific execution. It's useful for keeping data such as authentication info, the current user, database connection, data sources and other things you need for running your business logic.
The context is available as the 3rd argument to each resolver:
GraphQL Modules follow the same approach, so context is shared across modules. That's why there's no API for context building in GraphQL Modules, it's managed by GraphQL server implementation.
You can manage your own
context object based on your needs, usually it's done by the server implementation, since the
context object is created and filled with the HTTP request information (
request), which is a layer that comes before the actual GraphQL engine.
To get familiar with Dependency Injection, please read the "Dependency Injection - Introduction" chapter.
Context can be accessed directly in resolve function or within Dependency Injection using