Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
use-cache-in-ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
lemonmade committed Jun 27, 2019
1 parent bc6d096 commit 9762591
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/react-graphql/src/hooks/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export default function useQuery<

const query = useGraphQLDocument(queryOrComponent);

const normalizedFetchPolicy =
typeof window === 'undefined' && fetchPolicy === 'network-only'
? 'cache-first'
: fetchPolicy;
const serializedVariables = variables && JSON.stringify(variables);
const watchQueryOptions = useMemo<WatchQueryOptions<Variables> | null>(
() => {
Expand All @@ -55,7 +59,7 @@ export default function useQuery<
query,
context,
variables,
fetchPolicy,
fetchPolicy: normalizedFetchPolicy,
errorPolicy,
pollInterval,
notifyOnNetworkStatusChange,
Expand All @@ -67,7 +71,7 @@ export default function useQuery<
// eslint-disable-next-line react-hooks/exhaustive-deps
context && JSON.stringify(context),
serializedVariables,
fetchPolicy,
normalizedFetchPolicy,
errorPolicy,
pollInterval,
notifyOnNetworkStatusChange,
Expand Down

0 comments on commit 9762591

Please sign in to comment.