0.8.1 • Published 4 months ago
@graphql-ez/plugin-codegen v0.8.1
@graphql-ez/plugin-codegen
Integration with GraphQL Code Generator
Usage
import { ezCodegen } from '@graphql-ez/plugin-codegen';
const ezApp = CreateApp({
ez: {
plugins: [
ezCodegen({
// Options
}),
// ...
],
},
// ...
});
Options
The config
property extends the options of:
export interface CodegenConfig
extends TypeScriptPluginConfig,
TypeScriptResolversPluginConfig,
TypeScriptDocumentsPluginConfig,
TypeScriptTypedDocumentNodesConfig {
/**
* @description
* Will use import type {} rather than import {} when importing only types.
*
* This gives also add compatibility with TypeScript's "importsNotUsedAsValues": "error" option
*
* @default true
*/
useTypeImports?: boolean;
/**
* Enable deep partial type resolvers
*
* @default true
*/
deepPartialResolvers?: boolean;
/**
* Generated target path
*
* @default "./src/ez.generated.ts"
*/
targetPath?: string;
/**
* Add arbitrary code at the beginning of the generated code
*/
preImportCode?: string;
/**
* Handle Code Generation errors
* @default console.error
*/
onError?: (err: unknown) => void;
/**
* Custom Code Generation finish callback
*/
onFinish?: () => void;
/**
* GraphQL Codegen plugin context
*/
pluginContext?: Record<string, any>;
/**
* Extra plugins map
*/
extraPluginsMap?: Record<string, CodegenPlugin<any>>;
/**
* Extra plugins config
*/
extraPluginsConfig?: Types.ConfiguredPlugin[];
/**
* Asynchronously loads executable documents (i.e. operations and fragments) from
* the provided pointers. The pointers may be individual files or a glob pattern.
* The files themselves may be `.graphql` files or `.js` and `.ts` (in which
* case they will be parsed using graphql-tag-pluck).
*/
documents?: UnnormalizedTypeDefPointer | UnnormalizedTypeDefPointer[];
/**
* Documents config
*/
documentsConfig?: {
/**
* @default true
*/
useTypedDocumentNode?: boolean;
/**
* Configuration used while loading the documents
*/
loadDocuments?: Partial<LoadTypedefsOptions>;
};
/**
* Skip documents validation
*/
skipDocumentsValidation?: boolean;
/**
* Transform the generated code
*/
transformGenerated?: (code: string) => string | Promise<string>;
/**
* Custom document loaders
*/
documentsLoaders?: Loader<string, SingleFileOptions>[];
}
export interface CodegenOptions {
/**
* Enable code generation, by default is enabled if `NODE_ENV` is not `production` nor `test`
*
* @default process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test"
*/
enableCodegen?: boolean;
/**
* Add custom codegen config
*/
config?: CodegenConfig;
/**
* Output schema target path or flag
*
* If `true`, defaults to `"./schema.gql"`
* You have to specify a `.gql`, `.graphql` or `.json` extension
*
* @default false
*/
outputSchema?: boolean | string | string[];
}
0.8.1
4 months ago
0.7.12
1 year ago
0.8.0
1 year ago
0.7.11
2 years ago
0.7.10
2 years ago
0.7.9
2 years ago
0.7.8
2 years ago
0.7.7
2 years ago
0.7.6
2 years ago
0.7.5
2 years ago
0.7.4
3 years ago
0.7.3
3 years ago
0.7.2
3 years ago
0.7.1
3 years ago
0.7.0
3 years ago
0.6.3
3 years ago
0.6.2
3 years ago
0.6.1
3 years ago
0.6.0
3 years ago
0.5.0
3 years ago
0.4.0
3 years ago
0.3.4
3 years ago
0.3.3
3 years ago
0.3.2
3 years ago
0.3.1
3 years ago
0.3.0
3 years ago
0.1.2
3 years ago
0.2.0
3 years ago
0.1.1
3 years ago
0.1.0
3 years ago