Last 12 weeks ยท 11 commits
4 of 6 standards met
Describe the bug In 's input normalization, a plain argument is deep-wrapped in a Vue reactive proxy before it reaches Apollo Client, so the document Apollo receives is not the object the caller passed. The cause is here (current tip): https://github.com/vuejs/apollo/blob/69d9097548a3/packages/vue-apollo-composable/src/useQuery.ts#L968 For the most common documented call form, , falls through to , and deep-converts objects โ so is , not . Reproduction Observed on with 4.2.3 and Vue 3.5; the normalization is unchanged at the current tip (69d9097). Why this matters 1. Document identity is load-bearing in Apollo Client. Per-document caches (document transform cache, cache) are WeakMaps keyed by object reference. The proxy and the raw constant are different keys, so the same operation used both through and directly (, , SSR code) is transformed and printed separately. 2. Identity-based matching can silently miss. APIs that match operations by document โ e.g. after a mutation โ see a different object than the one the observable query was registered with, since each is routed through the transform cache under its own key. 3. Needless reactivity overhead. Every AST node Apollo touches while transforming/printing the document is tracked as a dependency of a proxy that will never mutate. Suggested fix Normalize with a getter instead of , which supports the same input surface but never converts the returned value, preserving referential identity for plain constants, refs, and getters alike: Happy to send a PR if this shape is acceptable. Workaround Pass a getter: โ wraps getters in a non-converting readonly ref, so identity is preserved. Context Found while porting a production React + Apollo Client 4 app to Vue 3.5 against the v5 alpha โ an Apollo-level parity test suite flagged the identity loss.
Repository: vuejs/apollo. Description: ๐ Apollo/GraphQL integration for VueJS Stars: 6032, Forks: 517. Primary language: TypeScript. Languages: TypeScript (91.8%), Vue (7.7%), CSS (0.4%). License: MIT. Homepage: http://apollo.vuejs.org Topics: apollographql, graphql, vue, vue2, vuejs, vuejs2. Latest release: v4.2.3 (1mo ago). Open PRs: 9, open issues: 266. Last activity: 2w ago. Community health: 75%. Top contributors: Akryum, dependabot-preview[bot], nickmessing, ydfzgyj, bbugh, Austio, NataliaTepluhina, ciscorn, escapedcat, joe-re and others.