dotansimha / dotansimha/graphql-code-generator-community
@graphql-codegen/typescript-graphql-request uses wrong import for gql in ESM
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
### Which packages are impacted by your issue?
@graphql-codegen/typescript-graphql-request
### Describe the bug
If you try to generate a ESM compatible sdk with `@graphql-codegen/typescript-graphql-request` it imports `gql` namespace, instead of `{gql}` function
### Your Example Website or App
https://the-guild.dev/graphql/codegen
### Steps to Reproduce the Bug or Issue
1. Go to https://the-guild.dev/graphql/codegen
2. Provide this codegen.yml:
```yml
generates:
sdk.ts:
plugins:
- typescript
- typescript-graphql-request
config:
emitLegacyCommonJSImports: false
```
3. See the
```typescript
import gql from 'graphql-tag';
```
### Expected behavior
should output
```typescript
import {gql} from 'graphql-tag';
```
### Screenshots or Videos
_No response_
### Platform
- OS: Linux
- NodeJS: 18.15.0
- `graphql` version: 16.6.0
- `@graphql-codegen/typescript-graphql-request` version: 4.5.9
### Codegen Config File
_No response_
### Additional context
Workaround:
```typescript
// gql-fix.ts
import { gql } from "graphql-tag";
export { gql };
```
and use it like:
```yml
generates:
sdk.ts:
plugins:
- typescript
- typescript-graphql-request
config:
emitLegacyCommonJSImports: false
gqlImport: ./gql-fix.js#gql,
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.