dotansimha / dotansimha/graphql-code-generator
client-preset generates imports incompatible with moduleResolution=node16
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
### Which packages are impacted by your issue?
@graphql-codegen/client-preset
### Describe the bug
Preset generates imports like `import * as types from './graphql';` which are not compatible with TypeScript in ESM mode with `moduleResolution` `node16`.
### Your Example Website or App
any schema will do
### Steps to Reproduce the Bug or Issue
Simply run codegen build.
### Expected behavior
When `emitLegacyCommonJSImports` is disabled, imports should be ESM-compatible.
### Screenshots or Videos
_No response_
### Platform
- OS: MacOS
- NodeJS: 20
- @graphql-codegen/cli: 5.0.2
- @graphql-codegen/client-preset: 4.3.2
### Codegen Config File
```typescript
export default {
schema: "./src/schema.json",
documents: ["./src/queries/*.graphql"],
generates: {
"./src/gql/": {
preset: "client",
presetConfig: {
useTypeImports: true,
},
config: {
emitLegacyCommonJSImports: false,
},
},
},
};
```
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.