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

feat: support discriminating null and undefined within useFragment #10001

Merged
merged 2 commits into from
Jun 13, 2024

Conversation

n1ru4l
Copy link
Collaborator

@n1ru4l n1ru4l commented Jun 13, 2024

Closes #9038

Support discriminating null and undefined within the useFragment function.

function MyComponent(props: FragmentType<typeof MyFragment> | null) {
  const data = useFragment(MyFragment, props)
  // data is `MyFragment | null`
}

function MyComponent(props: FragmentType<typeof MyFragment> | undefined) {
  const data = useFragment(MyFragment, props)
  // data is `MyFragment | undefined`
}

Before, the returned type from useFragment was always TType | null | undefined.

Copy link

changeset-bot bot commented Jun 13, 2024

🦋 Changeset detected

Latest commit: d6aed3b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphql-codegen/client-preset Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Jun 13, 2024

💻 Website Preview

The latest changes are available as preview in: https://66f31c79.graphql-code-generator.pages.dev

Copy link
Contributor

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-codegen/client-preset 4.3.0-alpha-20240613090024-d6aed3bdf27fcee9415cade51ba666bc4827e049 npm ↗︎ unpkg ↗︎

@n1ru4l n1ru4l merged commit 1be6e65 into master Jun 13, 2024
19 checks passed
@n1ru4l n1ru4l deleted the feat-null-undefined-discriminate branch June 13, 2024 09:11
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 this pull request may close these issues.

client useFragment null discrimination
1 participant