Skip to content

A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.

License

Notifications You must be signed in to change notification settings

gallery-so/graphql-code-generator

 
 

Repository files navigation

Hello 👋

This is Gallery's fork of [https://github.com/dotansimha/graphql-code-generator]. More specifically, a fork of the @graphql-codegen/typescript-oeprations package.

What does this fork do?

We simply add the id field to any type that has it available to match Relay's expectations. See below 👇.

Why might you need this?

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.

How to use this package?

  1. Remove @graphql/typescript-operations
    yarn remove @graphql/typescript-operations
  2. Install @gallery-so/typescript-operations
    yarn add @gallery-so/typescript-operations
  3. Update your codegen.yml file to include the autoSelectId field.
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"

About

A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 98.8%
  • JavaScript 1.2%