Skip to main content

import-types

This preset generates a file per each operation file, and allow to import types from another file.

Installation

import-types-preset plugin version
Using yarn
yarn add -D @graphql-codegen/import-types-preset

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

generates:
path/to/file.ts:
preset: import-types
presetConfig:
typesPath: types.ts
plugins:
- typescript-operations

importTypesNamespace

type: string default: Types

Optional, override the name of the import namespace used to import from the baseTypesPath file.

Usage Examples

generates:
src/:
preset: import-types
presetConfig:
typesPath: types.ts
importTypesNamespace: SchemaTypes
plugins:
- typescript-operations