Skip to content

Conversation

@vicary
Copy link
Member

@vicary vicary commented Dec 12, 2025

Workaround for facebook/react#35126

Caveats:

  1. In core this stops out-of-resolve proxy access from triggering a silent refetch, undocumented so we assume it's fine.
  2. Now it explicity tracks a render depth counter for each calls to useQuery() in development mode.

Copy link
Contributor

Copilot AI left a 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 useQuery hook's proxy to only expose $refetch and $state during enumeration, hiding schema fields from React's prop diffing
  • Added activeEnumerators counter 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.

Copy link
Contributor

Copilot AI left a 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.

@vicary vicary force-pushed the fix(package/react)-react-19.2-object-props branch 2 times, most recently from 267861b to 7dd31bf Compare December 12, 2025 12:14
@vicary vicary force-pushed the fix(package/react)-react-19.2-object-props branch from 7dd31bf to 0328043 Compare December 12, 2025 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants