-
-
Notifications
You must be signed in to change notification settings - Fork 33
fix(package/react): Prevent bloated fetches in React ~19.2 dev mode #2306
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes bloated fetches in React 19.2 dev mode by preventing unintended field selections during React's prop diffing, addressing facebook/react#35126. The fix implements a two-part solution: restricting enumeration on the React query proxy to prevent React from seeing all schema fields, and adding an activeEnumerators counter in the gqty core to allow helpers like selectFields() to explicitly opt-in to full enumeration.
Key Changes
- Modified
useQueryhook's proxy to only expose$refetchand$stateduring enumeration, hiding schema fields from React's prop diffing - Added
activeEnumeratorscounter to the schema context that enables helpers to enumerate all fields while preventing accidental enumeration by React - Refactored object proxy handler from a global singleton to a factory function that respects the enumeration flag
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
packages/react/src/query/useQuery.ts |
Refactored proxy to restrict enumeration to custom properties only, preventing React 19 dev mode from enumerating schema fields |
packages/gqty/src/Client/context.ts |
Added activeEnumerators counter to track when intentional enumeration is allowed |
packages/gqty/src/Accessor/resolve.ts |
Converted global proxy handler to factory function and implemented conditional enumeration based on activeEnumerators flag |
packages/gqty/src/Helpers/selectFields.ts |
Wrapped enumeration logic to increment/decrement activeEnumerators counter |
packages/gqty/src/Helpers/getFields.ts |
Added similar counter wrapping to allow full schema enumeration in helper functions |
.changeset/open-cooks-thank.md |
Changeset for React package minor version bump |
.changeset/early-yaks-visit.md |
Changeset for gqty package minor version bump |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
267861b to
7dd31bf
Compare
7dd31bf to
0328043
Compare
Workaround for facebook/react#35126
Caveats:
useQuery()in development mode.