Skip to content

Commit

Permalink
fix(react): prioritise context.suspense (#3427)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Nov 13, 2023
1 parent 3fe5b14 commit f2c59c5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/real-geese-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'urql': patch
'@urql/preact': patch
---

Prioritise `context.suspense` and fallback to checking `client.suspense`
4 changes: 3 additions & 1 deletion packages/preact-urql/src/hooks/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ function toSuspenseSource<T>(source: Source<T>): Source<T> {
}

const isSuspense = (client: Client, context?: Partial<OperationContext>) =>
client.suspense && (!context || context.suspense !== false);
context && context.suspense !== undefined
? !!context.suspense
: client.suspense;

const sources = new Map<number, Source<OperationResult>>();

Expand Down
4 changes: 3 additions & 1 deletion packages/react-urql/src/hooks/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ export type UseQueryResponse<
> = [UseQueryState<Data, Variables>, UseQueryExecute];

const isSuspense = (client: Client, context?: Partial<OperationContext>) =>
client.suspense && (!context || context.suspense !== false);
context && context.suspense !== undefined
? !!context.suspense
: client.suspense;

/** Hook to run a GraphQL query and get updated GraphQL results.
*
Expand Down

0 comments on commit f2c59c5

Please sign in to comment.