dotansimha / dotansimha/graphql-code-generator

issues with generated file after react query v5 migration

Open
#9,824 2 comments 1 reaction 0 assignees 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/cli

### Describe the bug

I'm having several issues after migrating tanstack query to v5. Is there anything I might have missed in the codegen.ts? how can I fix the warnings in generated.ts.

how do I pass options to the query? the app doesn't want to start due to bad argument type

```
const currentUserQuery = useCurrentUserQuery({ enabled: !isLoggingIn });
TS2322: Type boolean is not assignable to type never
```

### Your Example Website or App

can't share

### Steps to Reproduce the Bug or Issue

1. upgrade react query

### Expected behavior

no warnings in generated.ts and no issues with useQuery or useMutation hooks

### Screenshots or Videos

![image](https://github.com/dotansimha/graphql-code-generator/assets/31188583/1f0f6332-1888-4649-8fb5-7f6cb46fc919)

`const currentUserQuery = useCurrentUserQuery({ enabled: !isLoggingIn });`
`TS2322: Type boolean is not assignable to type never`

### Platform

- OS: macOS
- NodeJS: 18.18.2
- `graphql` version: 16.8.1
- `@graphql-codegen/*` version(s): [e.g. 2.6.2]

```
"dependencies": {
"@graphql-codegen/cli": "5.0.0",
"@graphql-codegen/typescript-operations": "4.0.1",
"@graphql-codegen/typescript-react-query": "6.0.0",
"@graphql-eslint/eslint-plugin": "3.20.1",
"@graphql-typed-document-node/core": "3.2.0",
"@tanstack/eslint-plugin-query": "4.34.1",
"@tanstack/react-query": "5.17.19",
```

Codegen Config File

```
import type { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
overwrite: true,
schema: '../schema.graphql',
reactQueryVersion: 5,
documents: 'src/**/*.graphql',
generates: {
'src/generated/generated.ts': {
plugins: ['typescript', 'typescript-operations', 'typescript-react-query'],
config: {
fetcher: '../fetcher#fetcher',
namingConvention: {
enumValues: 'keep',
},
},
},
},
};

export default config;

```

### Additional context

_No response_

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.