graphql-code-generator
graphql-code-generator copied to clipboard
emitLegacyCommonJSImports doesn't work with fragment imports
trafficstars
Describe the bug
After https://github.com/dotansimha/graphql-code-generator/pull/8077 generation always emits .js extension. Reproducable only in [email protected], in 2.3.1 everything ok.
Your Example Website or App
Steps to Reproduce the Bug or Issue
- Generate using
near-file-operationspreset andemitLegacyCommonJSImports: trueoption. - Get import with
.jsextension - Get error because you use
typescript-operations
Expected behavior
I expect to generate without .js extension on atleast with .ts extension.
Screenshots or Videos
No response
Platform
- OS: macOS
- NodeJS: 16.9.1
graphqlversion: 16.3.0@graphql-codegen/*version(s): [e.g. 2.6.2]
Codegen Config File
schema: ${SCHEMA_URL}
documents: 'src/server/**/*.graphql'
hooks:
afterAllFileWrite:
- eslint --fix
- prettier --write
generates:
./src/server/graphqlSchema.ts:
config:
plugins:
- add: &scheme-add
content:
- '/**'
- ' * @generated This file was automatically generated and should not be edited.'
- ' */'
- typescript
./src/server/:
preset: near-operation-file
presetConfig:
extension: .ts
baseTypesPath: graphqlSchema.ts
importTypesNamespace: BFF
folder: __generated__
config:
gqlImport: graphql-tag#gql
nonOptionalTypename: true
addTypenameToSelectionSets: true
emitLegacyCommonJSImports: true
plugins:
- add: &operations-add
content:
- '/**'
- ' * @generated This file was automatically generated and should not be edited.'
- ' */'
- '/* eslint-disable @typescript-eslint/no-unused-vars */'
- typescript-operations
- typed-document-node
Additional context
No response