Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useFragment with array of nullable can't find type overload #10277

Open
igolka97 opened this issue Feb 4, 2025 · 1 comment · May be fixed by #10278
Open

useFragment with array of nullable can't find type overload #10277

igolka97 opened this issue Feb 4, 2025 · 1 comment · May be fixed by #10278

Comments

@igolka97
Copy link

igolka97 commented Feb 4, 2025

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

Image

Platform

see repro

Codegen Config File

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

@igolka97 igolka97 linked a pull request Feb 4, 2025 that will close this issue
9 tasks
@igolka97
Copy link
Author

igolka97 commented Feb 4, 2025

Prepared small PR to fix this issue #10278

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant