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] Add @unmask directive with field access warnings #11919

Merged
merged 103 commits into from
Jul 24, 2024

Conversation

jerelmiller
Copy link
Member

@jerelmiller jerelmiller commented Jul 1, 2024

Closes #11674
Closes #11673

Adds support for an @unmask directive that disables data masking for a named fragment when data masking is enabled in the client.

query {
  currentUser {
    id
    ...UserFields @unmask
  }
}

fragment UserFields on User {
  name
}

This directive will be most useful for migration when adopting data masking. As such, we've added the ability to emit warnings when using a mode argument set to migrate:

query {
  currentUser {
    id
    ...UserFields @unmask(mode: "migrate")
  }
}

fragment UserFields on User {
  name
}

When accessing data.currentUser.name, the user will see a warning in the console about accessing an unmasked field. Using @unmask without the mode argument won't emit warnings.

It is also possible to mix and match fragment subtrees with @unmask which allows a user to migrate a subtree at a time.

query {
  currentUser {
    ...UserFields @unmask(mode: "migrate")
  }
}

fragment UserFields on User {
  # will be masked
  ...UserSubfields

  # will emit warnings
  ...UserSubfields2 @unmask(mode: "migrate")

  # data will be available without warnings
  ...UserSubfields3 @unmask
}

Copy link

changeset-bot bot commented Jul 1, 2024

⚠️ No Changeset found

Latest commit: a924c0f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@jerelmiller jerelmiller force-pushed the jerel/unmask-directive branch from 24b0f20 to bead73f Compare July 2, 2024 14:34
@jerelmiller jerelmiller added the 🎭 data-masking Issues/PRs related to data masking label Jul 2, 2024
@jerelmiller jerelmiller added this to the Data masking milestone Jul 2, 2024
@jerelmiller jerelmiller force-pushed the jerel/unmask-warnings branch from ccce8ac to 5d0f2ad Compare July 16, 2024 18:23
@jerelmiller jerelmiller marked this pull request as ready for review July 18, 2024 23:44
@jerelmiller jerelmiller changed the title [Data masking] Add warnings when accessing masked fields while using @unmask directive [Data masking] Add @unmask directive with field access warnings Jul 23, 2024
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.

I had a bunch of suggestions, but I'd also be fine with it as it is.

src/core/masking.ts Outdated Show resolved Hide resolved
src/core/masking.ts Outdated Show resolved Hide resolved
src/core/masking.ts Outdated Show resolved Hide resolved
src/core/masking.ts Outdated Show resolved Hide resolved
src/core/masking.ts Show resolved Hide resolved
@github-actions github-actions bot added the auto-cleanup 🤖 label Jul 24, 2024
@jerelmiller jerelmiller merged commit b8a0d02 into data-masking Jul 24, 2024
32 checks passed
@jerelmiller jerelmiller deleted the jerel/unmask-warnings branch July 24, 2024 17:06
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-cleanup 🤖 🎭 data-masking Issues/PRs related to data masking
Projects
None yet
2 participants