This is Gallery's fork of [https://github.com/dotansimha/graphql-code-generator]. More specifically, a fork of the @graphql-codegen/typescript-oeprations package.
We simply add the id field to any type that has it available to match Relay's expectations. See below 👇.
If you're using Relay, you may already know that Relay will automatically select an id field if one is available in the schema. It's quite annoying when the generated types spit out by the codegen plugin don't match what Relay is expecting.
- Remove
@graphql/typescript-operationsyarn remove @graphql/typescript-operations
- Install
@gallery-so/typescript-operationsyarn add @gallery-so/typescript-operations
- Update your
codegen.ymlfile to include theautoSelectIdfield.
schema: ./schema.graphql
documents: ./src/**/*.{ts,tsx}
generates:
./src/__generated__/operations.ts:
config:
avoidOptionals: true
+ autoSelectId: true
plugins:
- typescript
- - typescript-operations
+ - "@gallery-so/typescript-operations"