-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
useQuery fails to resolve ssr renderPromise due to JSON.stringify reordering #11798
Comments
That's interesting - are you passing different variables in different situations here? That said, using |
Amazing, @phryneas. Thank you for the fast response. That's exactly what I found weird about it. We don't pass different variables to it (although I guess the react re-rendering recreates the objects/variables that are passed when the functional component gets re-executed). I tried getting |
I am also willing to make the contribution if you are short on time. Let me know. |
fixes #11798 This ensures that queries with variables of equal contents, but different order, will be handled the same way during `renderToStringWithData` SSR. It also replaces a hand-written Trie implementation with the `Trie` dependency.
I was already in the middle of the PR :) Could you try this build and report if it fixes your problem? npm i @apollo/client@0.0.0-pr-11799-20240422143231 |
I just tested it and it seems to fix our issue. Thank you for the help. |
…ie` (#11799) * `RenderPromises`: use `canonicalStringify` to serialize data, use `Trie` fixes #11798 This ensures that queries with variables of equal contents, but different order, will be handled the same way during `renderToStringWithData` SSR. It also replaces a hand-written Trie implementation with the `Trie` dependency. * Update .changeset/early-pots-rule.md Co-authored-by: Jerel Miller <jerelmiller@gmail.com> --------- Co-authored-by: Jerel Miller <jerelmiller@gmail.com>
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Issue Description
We found a bug in production where the
lookupQueryInfo()
method would consistently not render a SSR component after callingrenderToStringWithData
.Upon investigation, we found that the query was being executed and the result should have been available. However, a second
QueryInfo
would be registered instead of recovering the resolved one. This is due to theJSON.stringify
method switching the order of attributes when looking up the Map (Check screenshots).I noticed the utilities package already provides a
canonicalStringify
which would fix this issue.Link to Reproduction
https://github.com/apollographql/apollo-client/blob/main/src/react/ssr/RenderPromises.ts#L140
Reproduction Steps
No response
@apollo/client
version3.8.3
The text was updated successfully, but these errors were encountered: