Skip to content

Import of custom fetcher should never by a type import #10501

@albertodeago

Description

@albertodeago

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

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions