Skip to content

Commit

Permalink
add defer handling to fragment-spread
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Apr 23, 2024
1 parent 1187faf commit 4aa9096
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/react-urql/src/hooks/useFragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,19 +279,16 @@ const maskFragment = <Data>(
} else if (selection.kind === Kind.FRAGMENT_SPREAD) {
const fragment = fragments[selection.name.value];

if (
const hasDefer =
selection.directives &&
selection.directives.find(x => x.name.value === 'defer')
) {
return;
}
selection.directives.find(x => x.name.value === 'defer');

if (!fragment || !isHeuristicFragmentMatch(fragment, data, fragments)) {
return;
}

const result = maskFragment(data, fragment.selectionSet, fragments);
if (!result.fulfilled && !hasIncludeOrSkip) {
if (!result.fulfilled && !hasIncludeOrSkip && !hasDefer) {
isDataComplete = false;
}
Object.assign(maskedData, result.data);
Expand Down

0 comments on commit 4aa9096

Please sign in to comment.