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

Allow fragment refs to be null or undefined #94

Merged
merged 5 commits into from
Mar 20, 2024

Conversation

Markionium
Copy link
Member

Relay allows for fragment references to be null or undefined. Our typings have been stricter where they do not allow null or undefined.

This causes us to miss out on things like @skip and @include.

This PR adds the ability to pass null or undefined as the fragment reference to useFragment usePaginationFragment or useRefetchableFragment.

@@ -193,6 +252,39 @@ export function usePaginationFragment<
isLoadingNext: boolean;
isLoadingPrevious: boolean;
refetch: RefetchFn<TQuery["variables"]>;
};
export function usePaginationFragment<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this definition different from one below?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mean the one with the implementation then it isn't different. But afaik you can't have the implementation serve as one of the definitions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, one is definition the other implementation

@Markionium Markionium force-pushed the make-fragment-ref-nullable branch from 96ddc10 to 960ca0b Compare March 19, 2024 10:03
Copy link
Member

@alloy alloy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just some minor feedback 👍

packages/nova-react/src/graphql/hooks.test.tsx Outdated Show resolved Hide resolved
packages/nova-react/src/graphql/hooks.test.tsx Outdated Show resolved Hide resolved
packages/nova-react/src/graphql/hooks.test.tsx Outdated Show resolved Hide resolved
packages/nova-react/src/graphql/hooks.ts Show resolved Hide resolved
packages/nova-react/src/graphql/hooks.ts Outdated Show resolved Hide resolved
@alloy alloy merged commit 78f7c8c into microsoft:main Mar 20, 2024
2 checks passed
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.

3 participants