dotansimha / dotansimha/graphql-code-generator

emitLegacyCommonJSImports doesn't work with fragment imports

Open
#8,186 0 comments 0 reactions 0 assignees View on GitHub
core
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### Describe the bug

After https://github.com/dotansimha/graphql-code-generator/pull/8077 generation always emits `.js` extension. Reproducable only in `typed-document-node@2.3.2`, in `2.3.1` everything ok.

### Your Example Website or App

-

### Steps to Reproduce the Bug or Issue

1. Generate using `near-file-operations` preset and `emitLegacyCommonJSImports: true` option.
2. Get import with `.js` extension
3. 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
- `graphql` version: 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_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.