dotansimha / dotansimha/graphql-code-generator-community
react-query plugin with graphql-request fetcher generates invalid infinite query if query has no arguments
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
### Describe the bug
The latest version introduces an issue where, if an infinite query has no arguments, the `react-query` plugin generates invalid types.
### Your Example Website or App
/
### Steps to Reproduce the Bug or Issue
1. write a query without arguments
2. observe type error in generated code
The error comes from the 3rd argument passed to fetcher:
```
error TS2345: Argument of type '{ [x: string]: any; }' is not assignable to parameter of type 'Exact<{ [key: string]: never; }>'.
'string' index signatures are incompatible.
Type 'any' is not assignable to type 'never'.
```
### Expected behavior
No error.
### Screenshots or Videos
_No response_
### Platform
- OS: macOS
- NodeJS: 16.7.1
- `graphql` version: 16.6.0
```
"@graphql-codegen/cli": "^2.13.7",
"@graphql-codegen/typescript": "^2.8.0",
"@graphql-codegen/typescript-graphql-request": "^4.5.7",
"@graphql-codegen/typescript-operations": "^2.5.5",
"@graphql-codegen/typescript-react-query": "^4.0.3",
```
### Codegen Config File
`scalars` omitted to keep it short
```
overwrite: true
generates:
src/modules/common/generated/client.graphql.ts:
documents: "src/**/*.graphql"
plugins:
- "typescript"
- "typescript-operations"
- "typescript-react-query"
config:
dedupeFragments: true
immutableTypes: true
skipTypename: true
maybeValue: T | null | undefined
namingConvention:
enumValues: keep
typeNames: keep
strictScalars: true
fetcher: graphql-request
exposeQueryKeys: true
addInfiniteQuery: true
```
### Additional context
Only happens in latest version.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.