graphql-codegen-typescript-operation-types
Version:
GraphQL codegen plugin that generates only the types used in the operations
35 lines (34 loc) • 1.56 kB
TypeScript
import { TypeScriptPluginConfig } from '@graphql-codegen/typescript';
/**
* @description This plugin generates the base TypeScript types used in the graphql operations.
*
* Intended as a drop in replacement for the typescript plugin but only generates the input, enums, and object types
* utilized in the graphql operations. Use one of the typescript or typescript-operation-types, not both.
*
* The types generated by this plugin are simple, and refers to the exact structure of your schema.
*
* This plugin is best used in conjunction with the typescript-operations plugin with `preResolveTypes: true` and setting
* `omitObjectTypes: true`. In this configuration this plugin will emit only the enum and input types used in the graphql
* mutations or queries.
*
* All scalar types are always emitted.
*/
export interface TypescriptOperationTypesPluginConfig extends Omit<TypeScriptPluginConfig, 'onlyOperationTypes'> {
/**
* @description Turns off emitting object, union, and interface types. Only the used inputs and enums and all scalars
* will be emitted. Interacts well with `preResolveTypes: true` of the typescript-operations plugin which will emit
* the operation fragments without referencing object types.
* @default false
*
* @exampleMarkdown Override all definition types
* ```yml
* generates:
* path/to/file.ts:
* plugins:
* - typescript-operation-types
* config:
* omitObjectTypes: true
* ```
*/
omitObjectTypes?: boolean;
}