dotansimha / dotansimha/graphql-code-generator

Import of custom fetcher should never by a `type` import

Open
#10,501 0 comments 1 reaction 1 assignee Claimed by @eddeee888 View on GitHub
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/visitor-plugin-common

### Describe the bug

When setting `useTypeImport` and providing a custom fetcher, the import of the custom fetcher is wrong

It's an import type, like `import type { fetcher } from '../fetcher';`
instead of being a "non-type" import like `import { fetcher } from '../fetcher';`

This makes the code not working as the fetcher is not imported in the bundle.

I cannot turn of the `useTypeImport` option because I've `verbatimModuleSyntax` turned on in my tsconfig.

### Your Example Website or App

[https://stackblitz.com/edit/github-52kpkfnf?file=\__generated_\_/graphql.ts]()

### Steps to Reproduce the Bug or Issue

code is already generated so you can look at the `__generated__/graphql.ts`, but to reproduce it

```sh
npm i
npm run codegen
```

### Expected behavior

The import for the custom fetcher should never be a type import

### Screenshots or Videos

*No response*

### Platform

* OS: macOS
* NodeJS: 22
* `graphql` version: 16.12.0
* `@graphql-codegen/*` version(s): 6.0.2
* `@graphql-codegen/cli` "^6.0.2",
* `@graphql-codegen/typescript` "^5.0.4",
* `@graphql-codegen/typescript-operations` "^5.0.4",
* `@graphql-codegen/typescript-react-query` "^6.1.1",

### Codegen Config File

*No response*

### Additional context

I believe the error is in the visitor-plugin-common, [here]() but I may be completely wrong

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.