GraphQL Code Generator's `@graphql-codegen/graphql-modules-preset` plugin helps to generate resolvers type for each module of a GraphQL Modules GraphQL API.
GraphQL Code Generator’s @graphql-codegen/graphql-modules-preset plugin helps to generate
resolvers type for each module of a GraphQL Modules GraphQL API.
Given the following GraphQL API structure using GraphQL Modules:
Assuming that, as recommended, your package.json has the following script:
package.json
{ "scripts": { "generate": "graphql-codegen" }}
Running the following generates the graphql/generated.tsx file.
npm run generate
yarn generate
pnpm run generate
bun run generate
The User module resolvers would be:
src/modules/user/resolvers.ts
import { UsersModule } from './generated-types/module-types'export const resolvers: UsersModule.Resolvers = { // Here, you can implement only the types and fields defined in your module!}