Import GraphQLModule.forRoot() with ApolloDriver and set autoSchemaFile to a path or true for in-memory. The driver option selects the underlying GraphQL server (Apollo or Mercurius). The context factory forwards the HTTP request into the GraphQL context so resolvers and guards can access it.
autoSchemaFile — path where the generated SDL is saved; set to true to keep it in memory only.
driver: ApolloDriver — NestJS supports Apollo (Express/Fastify) and Mercurius (Fastify-only).
context factory — builds the context object available inside every resolver; always forward req here.
sortSchema: true — alphabetically sorts the generated SDL for stable git diffs.
playground: true — enables the GraphQL Playground UI at /graphql in development.