fix(gqty): resolve crash and redundant fetches during prepareReactRender#2325
Open
schettn wants to merge 1 commit intogqty-dev:mainfrom
Open
fix(gqty): resolve crash and redundant fetches during prepareReactRender#2325schettn wants to merge 1 commit intogqty-dev:mainfrom
schettn wants to merge 1 commit intogqty-dev:mainfrom
Conversation
Improve SSR stability and performance by ensuring valid GraphQL generation for null
objects and deduplicating fetches for already-cached data.
- Update `resolve.ts` to fallback to leaf nodes or `__typename` for null objects
and empty arrays, preventing invalid GraphQL queries (e.g., `human { nullFather }`).
- Update `select.ts` to return `null` instead of `undefined` for sub-paths of
explicitly null nodes, correctly identifying resolved states.
- Implement a robust cache-aware filter in `prepareRender.ts` to skip redundant
fetches for data already hydrated in the cache.
- Optimize cache notification and preparation checks with recursive `hasValue` and
`hasMissing` helpers, replacing inefficient `flat(Infinity)` calls.
- Add comprehensive test cases in `useQuery.test.tsx` covering null object access
and partial cache hits in arrays during SSR.
schettn
commented
Apr 27, 2026
| @@ -489,49 +490,71 @@ describe('mutate accessors', () => { | |||
| } as unknown as Human); | |||
|
|
|||
| expect(owner).toMatchInlineSnapshot(` | |||
Author
There was a problem hiding this comment.
those are only whitespace changes.. sorry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve SSR stability and performance by ensuring valid GraphQL generation for null objects and deduplicating fetches for already-cached data.
resolve.tsto fallback to leaf nodes or__typenamefor null objects and empty arrays, preventing invalid GraphQL queries (e.g.,human { nullFather }).select.tsto returnnullinstead ofundefinedfor sub-paths of explicitly null nodes, correctly identifying resolved states.prepareRender.tsto skip redundant fetches for data already hydrated in the cache.hasValueandhasMissinghelpers, replacing inefficientflat(Infinity)calls.useQuery.test.tsxcovering null object access and partial cache hits in arrays during SSR.Note: @vicary All newly added test cases were verified to fail prior to these changes, confirming the identified bugs. While all existing tests continue to pass, please review the implementation for any unintended side effects or if an alternative architectural approach is preferred.