GraphQL Modules comes with a built-in support for GraphQL Code Generator
To get started, add
@graphql-codegen/cli and necessary templates to your app:
schema.ts to expose the schema of your GraphQL Modules application.
GraphQL Modules won't load any other things such as injectors, resolvers and providers when you just try to get type definitions from your top module, because GraphQL Modules loads every part of module lazily.
Exposing Schema to GraphQL Code Generator
src/schema.tsto expose your type definitions to GraphQL Code Generator without any business logic.
Creating Configuration for GraphQL Code Generator
codegen.yml on your project root.
In the example below, TypeScript files are emitted.
Check the GraphQL Code Generator website for more details.
You can add a script to
Using Generated Typings
Then you can use these generated typings everywhere in your project;
The article Writing Strict-Typed GraphQL TypeScript project w/ GraphQL Modules and GraphQL Code Generator explains why you would need this integration.