diff --git a/.changeset/real-geese-grow.md b/.changeset/real-geese-grow.md new file mode 100644 index 0000000000..ad4338734d --- /dev/null +++ b/.changeset/real-geese-grow.md @@ -0,0 +1,6 @@ +--- +'urql': patch +'@urql/preact': patch +--- + +Prioritise `context.suspense` and fallback to checking `client.suspense` diff --git a/packages/preact-urql/src/hooks/useQuery.ts b/packages/preact-urql/src/hooks/useQuery.ts index f30e97dde6..cf3c4f9e3e 100644 --- a/packages/preact-urql/src/hooks/useQuery.ts +++ b/packages/preact-urql/src/hooks/useQuery.ts @@ -212,7 +212,9 @@ function toSuspenseSource(source: Source): Source { } const isSuspense = (client: Client, context?: Partial) => - client.suspense && (!context || context.suspense !== false); + context && context.suspense !== undefined + ? !!context.suspense + : client.suspense; const sources = new Map>(); diff --git a/packages/react-urql/src/hooks/useQuery.ts b/packages/react-urql/src/hooks/useQuery.ts index 3e839155ff..673e420236 100644 --- a/packages/react-urql/src/hooks/useQuery.ts +++ b/packages/react-urql/src/hooks/useQuery.ts @@ -175,7 +175,9 @@ export type UseQueryResponse< > = [UseQueryState, UseQueryExecute]; const isSuspense = (client: Client, context?: Partial) => - 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. *