Skip to content
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

[Data masking] Fix issue with @unmask(mode: "migrate") with nested partial objects from parent query #12134

Merged
merged 8 commits into from
Nov 15, 2024

Conversation

jerelmiller
Copy link
Member

Fixes an issue where a query selects some fields from an object and warnings are applied to a fragment that selects from the same selection set with more fields. Currently the additional fields are masked accidentally. See the test for a reproduction.

@svc-apollo-docs
Copy link

svc-apollo-docs commented Nov 15, 2024

✅ Docs Preview Ready

No new or changed pages found.

Copy link

changeset-bot bot commented Nov 15, 2024

🦋 Changeset detected

Latest commit: dcc61a7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@apollo/client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented Nov 15, 2024

npm i https://pkg.pr.new/@apollo/client@12134

commit: 28c7338

@@ -434,3 +447,52 @@ function warnOnImproperCacheImplementation() {
);
}
}

function backfillFieldsWithWarnings(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Halp. This sucks. Its late so @phryneas if you have ideas on how to make this better, I'd love your feedback.

The goal of this particular function is to merge two objects that look something like this:

const albumInQuery = {
  id: '1',
  __typename: 'Album',
}

const albumWithWarnings = {
  id: '1',
  images: [...] // (get/set) with warnings
  __typename: 'Album'
}

Where accessing album.id and album.__typename would not emit warnings (since they are in the parent query), but accessing album.images would since its part of the fragment unmasked with warnings.

@jerelmiller jerelmiller force-pushed the jerel/fix-arrays branch 2 times, most recently from 8848206 to 52be1e0 Compare November 15, 2024 16:01
Base automatically changed from jerel/fix-nested-null to release-3.12 November 15, 2024 17:42
@jerelmiller jerelmiller marked this pull request as ready for review November 15, 2024 17:46
Copy link
Contributor

github-actions bot commented Nov 15, 2024

size-limit report 📦

Path Size
dist/apollo-client.min.cjs 40.66 KB (+0.09% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" 51.12 KB (+0.18% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" (production) 47.65 KB (+0.16% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" 36.38 KB (+0.16% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" (production) 33.59 KB (+0.11% 🔺)
import { ApolloProvider } from "dist/react/index.js" 1.26 KB (0%)
import { ApolloProvider } from "dist/react/index.js" (production) 1.24 KB (0%)
import { useQuery } from "dist/react/index.js" 5.21 KB (0%)
import { useQuery } from "dist/react/index.js" (production) 4.3 KB (0%)
import { useLazyQuery } from "dist/react/index.js" 5.71 KB (0%)
import { useLazyQuery } from "dist/react/index.js" (production) 4.78 KB (0%)
import { useMutation } from "dist/react/index.js" 3.62 KB (0%)
import { useMutation } from "dist/react/index.js" (production) 2.85 KB (0%)
import { useSubscription } from "dist/react/index.js" 4.43 KB (0%)
import { useSubscription } from "dist/react/index.js" (production) 3.48 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" 5.51 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" (production) 4.17 KB (0%)
import { useBackgroundQuery } from "dist/react/index.js" 5.01 KB (0%)
import { useBackgroundQuery } from "dist/react/index.js" (production) 3.66 KB (0%)
import { useLoadableQuery } from "dist/react/index.js" 5.09 KB (0%)
import { useLoadableQuery } from "dist/react/index.js" (production) 3.74 KB (0%)
import { useReadQuery } from "dist/react/index.js" 3.42 KB (0%)
import { useReadQuery } from "dist/react/index.js" (production) 3.36 KB (0%)
import { useFragment } from "dist/react/index.js" 2.37 KB (0%)
import { useFragment } from "dist/react/index.js" (production) 2.31 KB (0%)

@jerelmiller jerelmiller merged commit cfaf4ef into release-3.12 Nov 15, 2024
32 of 36 checks passed
@jerelmiller jerelmiller deleted the jerel/fix-arrays branch November 15, 2024 17:57
@github-actions github-actions bot mentioned this pull request Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants