dotansimha / dotansimha/graphql-code-generator
useFragment with array of nullable can't find type overload
- 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/client-preset
### Describe the bug
When using fragment and fragment masking on a graphql field with type like `[Film]!` or `[Film]` typescript returns error about it cant find matching overload.
### Your Example Website or App
https://codesandbox.io/p/devbox/gifted-brook-d5q8gx?workspaceId=ws_3UmFdMnhnojzcbNhGuKYwW
### Steps to Reproduce the Bug or Issue
1. Create graphql query like `users: [User]!`
2. Create type `User` and it's fragment
3. Generate with client-preset
4. try to use `useFragment` with User fragment
5. got TS error
### Expected behavior
No TS error
### Screenshots or Videos
### Platform
see repro
### Codegen Config File
```js
import { CodegenConfig } from "@graphql-codegen/cli";
const config: CodegenConfig = {
schema: "schema.graphql",
documents: "document.graphql",
generates: {
"graphql/generated/": {
preset: "client",
plugins: [],
},
},
};
export default config;
```
### Additional context
I found out that there are no overloads for useFragment in generated `fragment-masking.ts` for arrays with nullable elements
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.