dotansimha / dotansimha/graphql-code-generator-community

[typescript-react-query] custom fetcher is imported as type when `useTypeImports` is true

Open
#152 2 comments 6 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
137
Forks
195
Avg merge
6h 20m
Merged PRs (30d)
16

Description

**Describe the bug**
I've set `useTypeImports: true` in my config, but it is causing my custom `fetcher` in `typescript-react-query` to be imported as a type, which does not work.

**To Reproduce**
Steps to reproduce the behavior:

https://codesandbox.io/s/graphql-code-generator-6904-40u7s?file=/src/getUser.generated.ts:97-126

Note the `import type {customFetcher}`, which is incorrect.

3. My `codegen.yml` config file:

```yml
generates:
./src/types.ts:
plugins:
- typescript
./src:
preset: near-operation-file
presetConfig:
baseTypesPath: ./types.ts
plugins:
- typescript-operations
- typescript-react-query
config:
useTypeImports: true
fetcher:
func: './src/api/fetch#customFetcher'
```

**Expected behavior**
The custom fetcher should be imported as value, not as type.

**Environment:**

- OS: mac
- `@graphql-codegen/...`: See reproduction
- NodeJS: 16

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.