Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 1.7 KB

File metadata and controls

38 lines (26 loc) · 1.7 KB

Linear Codegen Document

This custom graphql-code-generator plugin takes the Linear GraphQL schema and generates GraphQL fragments and operations.

Usage in codegen.doc.yml.

Output

The @linear/sdk uses this code generator plugin to generate:

A fragment for each model in the Linear API containing:

  • all scalar fields on the model
  • required fields for any nested object with a matching query
  • fragment spreads for any nested object with no matching query

An operation for each query and mutation in the Linear API containing:

  • all available variables
  • fragment spread for the matching model

An operation for each nested query within a model containing:

  • all available variables for both the root and child query
  • fragment spread for the matching child model
  • a query name joining the root and child query fields (eg query user_assignedIssues)

Flow

  1. The GraphQL schema is parsed using a reusable ContextVisitor to provide consistent information across the Linear code generator plugins
  2. The context is visited using the FragmentVisitor to return a list of printed GraphQL fragments
  3. The fragments and context are visited using the OperationVisitor to return a list of printed GraphQL operations
  4. The printed fragments and operations are returned to be printed

License


Licensed under the MIT License.