This custom graphql-code-generator plugin takes the Linear GraphQL GraphQL fragments and operations, generated by the Linear Codegen Document, and outputs a typed jest test. This aims to tests exposes all GraphQL models and operations available on the introspection query.
Usage must contain a neighbouring test-client file to expose two functions:
startClientto optionally start a mock GraphQL server, used in thebeforeAllhookstopClientto optionally stop a mock GraphQL server, used in theafterAllhook
It requires that GraphQL types-document-nodes have been generated and linked to this plugin using the codegen config documentFile property, using the plugins:
- @graphql-codegen/typescript
- @graphql-codegen/typescript-operations
- @graphql-codegen/typed-document-node
Usage in codegen.test.yml.
The @linear/sdk uses this code generator plugin to generate:
A describe block for each root query, that returns a model that is not an item of a collection, containing:
- a test to return the model, asserting the return type
- a test for each nested query on the model, or first item in a collection, asserting the return type
- The GraphQL schema is parsed using a reusable ContextVisitor to provide consistent information across the Linear code generator plugins
- The context is visited using the ModelVisitor to return a list of parsed Linear models
- The models and context are parsed to return a map of all operations for each nested resource
- The parsed models, operations and context are used to print tests
- The printed tests are returned to be printed
Licensed under the MIT License.