Import Types Preset
Package name | Weekly Downloads | Version | License | Updated |
---|---|---|---|---|
@graphql-codegen/import-types-preset | Sep 25th, 2023 |
Installation
npm i -D @graphql-codegen/import-types-preset
This preset generates a file per each operation file, and allow to import types from another file.
Config API Reference
typesPath
type: string
Required, should point to the base schema types file. The key of the output is used a the base path for this file.
Usage Examples
codegen.ts
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
// ...
generates: {
'path/to/file.ts': {
preset: 'import-types',
plugins: ['typescript-operations'],
presetConfig: {
typesPath: 'types.ts'
},
},
},
};
export default config;
importTypesNamespace
type: string
default: Types
Optional, override the name of the import namespace used to import from the baseTypesPath
file.
Usage Examples
codegen.ts
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
// ...
generates: {
'path/to/file.ts': {
preset: 'import-types',
plugins: ['typescript-operations'],
presetConfig: {
typesPath: 'types.ts',
importTypesNamespace: 'SchemaTypes',
},
},
},
};
export default config;