I've tried combining this plugin with the import-types preset, as follows, but couldn't get it to work.
The generated typed-document-nodes.ts file does get the import, but doesn't use it.
Here's the codegen.yml config file:
# graphql-codegen configuration
# Always replace files
overwrite: true
# Schema file to use as input
schema: ./apps/writer-plan/server/graphql/generated/schema.graphql
# All GraphQL queries (could also be extracted from TS files!)
documents: ./apps/writer-plan/client/graphql/queries/*.graphql
# Output to generate
generates:
./apps/writer-plan/client/graphql/generated/graphql.client.types.ts:
plugins:
- typescript
- typescript-operations
config:
immutableTypes: true
./apps/writer-plan/client/graphql/generated/typed-document-nodes.ts:
preset: import-types
presetConfig:
typesPath: ./graphql.client.types
# https://graphql-code-generator.com/docs/plugins/typescript-document-nodes
plugins:
- typed-document-node
hooks:
afterAllFileWrite:
- prettier --write
And the generated TS file:
import * as Types from './graphql.client.types';
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
import gql from 'graphql-tag';
export const PingDocument: DocumentNode<PingQuery, PingQueryVariables> = gql`
query ping {
ping {
message
timestamp
}
}
`;
As you can see, it does import the types, but doesn't use them below.
Hello,
I've tried combining this plugin with the import-types preset, as follows, but couldn't get it to work. The generated typed-document-nodes.ts file does get the import, but doesn't use it.
Here's the codegen.yml config file:
And the generated TS file:
As you can see, it does import the types, but doesn't use them below.
Am I using this incorrectly?