Import Types Preset
This preset generates a file per each operation file, and allow to import types from another file.
- Version
- 5.0.0
- Weekly downloads
- 504k
- License
- MIT
- Updated
- Nov 11, 2026
Installation
npm i -D @graphql-codegen/import-types-preset
yarn add -D @graphql-codegen/import-types-preset
pnpm add -D @graphql-codegen/import-types-preset
bun add -D @graphql-codegen/import-types-preset
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
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
Optional, override the name of the import namespace used to import from the baseTypesPath file.
Default value: “Types”
Usage Examples
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;This preset generates a file per each operation file, and allow to import types from another file.