@toptal/davinci-graphql-codegen-extensions v1.0.4
@toptal/davinci-graphql-codegen-extensions
A collection of extensions for the Graphql Code Generator.
The currently available extensions:
- Schema loader - preprocessor for GQL schema that filters out enum values hidden from the consumers
- Enums plugin - a plugin that generates a type for a mapping object between enum and the target type; by default all the enum values are required to be specified in the object, values that are marked with a special annotation become optional
Usage
Schema loader
The back-end can mark a new enum value as hidden with tt_earlySupportHidden
directive.
enum StatusEnum {
ACTIVE
INACTIVE
PENDING @tt_earlySupportHidden
}
Such annotated values will be removed from the schema used for types generation and won't be included in the Typescript enum.
Installation
Configure your schema to use @toptal/davinci-graphql-codegen-extensions/schema-loader
loader:
schema:
- schema.graphql
loader: @toptal/davinci-graphql-codegen-extensions/schema-loader
documents: ./src/**/*.graphql
generates:
./src/types.ts:
plugins:
- typescript
- typescript-operations
This will ensure that enum values with @HIDDEN
Enums plugin
The back-end can mark a new enum value as optional with tt_earlySupport
directive.
enum StatusEnum {
ACTIVE
INACTIVE
PENDING @tt_earlySupport
}
Installation
Add @toptal/davinci-graphql-codegen-extensions/enums-plugin
plugin to your configuration:
schema: schema.graphql
documents: ./src/**/*.graphql
generates:
./src/types.ts:
plugins:
- typescript
- @toptal/davinci-graphql-codegen-extensions/enums-plugin
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
4 months ago
5 months ago
5 months ago
6 months ago
9 months ago
10 months ago
10 months ago
6 months ago
10 months ago
8 months ago
7 months ago
6 months ago
8 months ago
6 months ago
6 months ago
10 months ago
7 months ago
7 months ago
6 months ago
6 months ago
7 months ago
7 months ago
7 months ago
10 months ago
10 months ago
6 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago