dotansimha / dotansimha/graphql-code-generator-community

[typescript-react-query] Does not use own types when combined with import-types and typescript-operations

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

Description

**Describe the bug**
I would like to separate out my schema-types from operation-types+hooks, and I believe I've found the config which should accomplish it. However, when using import-types-preset, _all_ of the types are referenced from the `Types` import, even if they're being exported from the same file.

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

https://codesandbox.io/s/graphql-code-generator-6909-lu5rm?file=/hooks.ts

Note typescript errors for `Types.UserQuery`, since `UserQuery` is defined in the same file, not `./types`.

1. My GraphQL schema:

See reproduction

2. My GraphQL operations:

See reproduction

3. My `codegen.yml` config file:

```yml
generates:
./types.ts:
plugins:
- typescript
./hooks.ts:
preset: import-types
presetConfig:
typesPath: ./types
plugins:
- typescript-operations
- typescript-react-query
```

**Expected behavior**
I expect that types being exported from `hooks.ts` are not attempted to be imported from `types.ts`.

**Environment:**

- OS: mac
- `@graphql-codegen/...`: latest, see reproduction
- NodeJS: 16

**Additional context**
A similar issue which was recently fixed: https://github.com/dotansimha/graphql-code-generator/issues/6520

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.