graphql-js
graphql-js copied to clipboard
Generator generates alias imports not compatible with TypeScript Type-Only Imports and verbatimModuleSyntax
By running npx graphql-code-generator graphql.ts files are generated with imports
import {TypedDocumentNode as DocumentNode} from '@graphql-typed-document-node/core'
that are not compatible with TypeScript configuration
tsconfig.ts
"compilerOptions": {
"verbatimModuleSyntax": true
}
It should be
import {type TypedDocumentNode as DocumentNode} from '@graphql-typed-document-node/core'
Documentation:
- https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html
- https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax
Is there any option to control how such imports are generated?
@lubos-bistak graphql-code-generator is not part of this organization and is not related to this repo. Can you please open issue in graphql-code-generator repo
This issue can be solved with
const config: CodegenConfig = {
...
generates: {
"src/gql/": {
...
config: {
useTypeImports: true
},
}
}
};
also described in https://github.com/dotansimha/graphql-code-generator/issues/9595