Skip to content

Commit

Permalink
Allow @defer to work in queries with suspense enabled (#3687)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewIngram authored Oct 7, 2024
1 parent 0438740 commit a5bc925
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/shiny-eagles-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'urql': minor
---

Support use of defer with suspense
7 changes: 6 additions & 1 deletion packages/react-urql/src/hooks/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,12 @@ export function useQuery<

const subscription = pipe(
source,
takeWhile(() => (suspense && !resolve) || !result),
takeWhile(
() =>
(suspense && !resolve) ||
!result ||
('hasNext' in result && result.hasNext)
),
subscribe(_result => {
result = _result;
if (resolve) resolve(result);
Expand Down

0 comments on commit a5bc925

Please sign in to comment.