-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Queries with ssr: false
get stuck in loading state and make no network request with ssrForceFetchDelay
#5918
Comments
Believe this is already a known issue |
@jjaybrown can you elaborate? I opened this because I can't find an existing issue. |
Is there any update on this? We are experiencing the same issue when we migrated Apollo Client from What happens is that on initial load from server, all of the data from SSR queries is loaded and rendered correctly, but the client side queries are not triggering any network requests after the initial render from server. The loading state for those queries stays always If we set Does anyone found a solution, or a workaround for that issue? |
We've had to workaround by not having SSR queries use that fetch policy, but it isn't a long term solution. Can we get an update on this? |
This workaround seems to be OK: import { useQuery as apolloUseQuery } from "@apollo/client";
export function useQuery(query, options) {
// force ssr: true on client
const ssr = typeof window === "undefined" ? options.ssr : true;
return apolloUseQuery(query, {
...options,
ssr,
});
} This may have negative effects I'm not aware of in other setups, though. |
Can people in this issue try 3.4 or the 3.5 beta and see if the issue is fixed. Sorry that this is happening and we should get SSR under control soon. |
This is likely fixed in |
@hwillson have you got a link to the fix PR? |
@hwillson Can you confirm how did you test it? It is still an issue for me. I have one doubt in this code here https://github.com/apollographql/apollo-client/blob/main/src/core/ApolloClient.ts#L170 This will create an issue here https://github.com/apollographql/apollo-client/blob/main/src/react/hooks/useQuery.ts#L299 if |
I have a page that has several fast queries and a few long-running ones, so I've decided to add
ssr: false
to defer the slower ones to the client.However after I added
ssrForceFetchDelay
to my client config, the ones withssr: false
policy got stuck in a loading state, and no network request's made to fetch the data.I seem to be missing something here, but is this the expected behavior?
Intended outcome:
The query that has
ssr: false
, running under a client that hasssrForceFetchDelay
, should fetch data when rendered client-side.Actual outcome:
The query got stuck in a loading state, and no network request's made to fetch the data.
How to reproduce the issue:
https://codesandbox.io/s/cool-mountain-u9dud
Notice the two queries with different
fetchPolicy
fail when usingssr: false
, and the query that has the default setting works.ssrMode
is set tofalse
in graphql/link.js andssrForceFetchDelay
is set to100
.Versions
(Also described in the codesandbox above)
The text was updated successfully, but these errors were encountered: