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

Ensure MaybeMasked doesn't unwrap if it contains any #12204

Merged
merged 11 commits into from
Dec 12, 2024

Conversation

jerelmiller
Copy link
Member

@jerelmiller jerelmiller commented Dec 9, 2024

Prevents MaybeMasked from unwrapping the type as Unmasked if the type contains any.

Example:

interface Source {
  foo: { bar: any[] };
}

This also ensures that types that contain tuples are not reduced down to an array of their subtypes.

interface Source {
  coords: [lat: number, long: number]
}

type A = Unmasked<Source> // 3.12.2 => { coords: number[] }
type B = Unmasked<Source> // 3.12.3 => { coords: [lat: number, long: number] }

This should fix the issue described in https://discord.com/channels/1022972389463687228/1315733932934959126/1315733932934959126

@jerelmiller jerelmiller added the 🎭 data-masking Issues/PRs related to data masking label Dec 9, 2024
Copy link

changeset-bot bot commented Dec 9, 2024

🦋 Changeset detected

Latest commit: 2f5963b

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

@svc-apollo-docs
Copy link

svc-apollo-docs commented Dec 9, 2024

✅ Docs Preview Ready

No new or changed pages found.

Copy link

pkg-pr-new bot commented Dec 9, 2024

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

commit: fc9f251

Copy link

netlify bot commented Dec 9, 2024

Deploy Preview for apollo-client-docs ready!

Name Link
🔨 Latest commit 2f5963b
🔍 Latest deploy log https://app.netlify.com/sites/apollo-client-docs/deploys/675adcf2d0c1970008c0659f
😎 Deploy Preview https://deploy-preview-12204--apollo-client-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

github-actions bot commented Dec 9, 2024

size-limit report 📦

Path Size
dist/apollo-client.min.cjs 40.64 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" 50.02 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" (production) 47.14 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" 36.14 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" (production) 33.54 KB (0%)
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.29 KB (0%)
import { useLazyQuery } from "dist/react/index.js" 5.7 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.84 KB (0%)
import { useSubscription } from "dist/react/index.js" 4.42 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.41 KB (0%)
import { useReadQuery } from "dist/react/index.js" (production) 3.35 KB (0%)
import { useFragment } from "dist/react/index.js" 2.36 KB (0%)
import { useFragment } from "dist/react/index.js" (production) 2.31 KB (0%)

@jerelmiller jerelmiller requested a review from phryneas December 9, 2024 21:12
Copy link
Member

@phryneas phryneas left a comment

Choose a reason for hiding this comment

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

Let's also wait for the user feedback on Discord if there is something else that gets past ContainsFragmentsRefs.

src/masking/__benches__/types.bench.ts Outdated Show resolved Hide resolved
@@ -20,7 +20,6 @@ export type UnwrapFragmentRefs<TData> =
>
>
>
: TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>>
Copy link
Member

Choose a reason for hiding this comment

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

👍

@jerelmiller jerelmiller marked this pull request as ready for review December 11, 2024 18:35
Copy link
Member

@phryneas phryneas left a comment

Choose a reason for hiding this comment

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

looks good!

@github-actions github-actions bot added the auto-cleanup 🤖 label Dec 12, 2024
@phryneas phryneas merged commit 851deb0 into main Dec 12, 2024
37 checks passed
@phryneas phryneas deleted the jerel/update-query-types branch December 12, 2024 13:03
@github-actions github-actions bot mentioned this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-cleanup 🤖 🎭 data-masking Issues/PRs related to data masking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants