-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 codemod to apply @unmask
to all named fragments
#12120
Conversation
🦋 Changeset detectedLatest commit: 65b06bb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
✅ Docs Preview ReadyNo new or changed pages found. |
commit: |
size-limit report 📦
|
d387561
to
ebf0d01
Compare
.changeset/flat-beans-knock.md
Outdated
Provide a codemod that applies `@unmask` to all named fragments for all operations and fragments. To use the codemod, run the following command: | ||
|
||
``` | ||
npx jscodeshift -t node_modules/@apollo/client/scripts/codemods/data-masking/unmask.ts --extensions tsx path/to/app/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to validate this is the correct path when the package is installed. So far I've been running this against the examples in this repo directly. If you'd like to do the same, the path to the unmask.ts
script should be:
npx jscodeshift -t scripts/codemods/data-masking/unmask.ts --extensions tsx scripts/codemods/data-masking/examples/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.changeset/flat-beans-knock.md
Outdated
``` | ||
npx jscodeshift -t node_modules/@apollo/client/scripts/codemods/data-masking/unmask.ts --extensions tsx path/to/app/ | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``` | |
npx jscodeshift -t node_modules/@apollo/client/scripts/codemods/data-masking/unmask.ts --extensions tsx path/to/app/ | |
``` | |
``` | |
npx jscodeshift -t node_modules/@apollo/client/scripts/codemods/data-masking/unmask.ts --extensions tsx --parser=tsx path/to/app/ | |
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from that, works nicely!
It would be great if it could change existing @unmask
to mode: "migrate"
, but that would be a bonus feature for a later time I guess ^^
Only thing we still have to figure out is distribution.
Co-authored-by: Lenz Weber-Tronic <lorenz.weber-tronic@apollographql.com>
I considered that but left it for now because I thought that this might happen as a result of manually adding Should be easy to update though if we get feedback that it should update existing directives. If you feel strongly that we should have this out of the gate, I'd be happy to implement it. |
Please don't let that be a blocker! It would be a nice to have and I'm not even sure if it's very useful, so let's wait on that for user feedback! |
We still need to figure out the distribution strategy for the codemod, but that shouldn't hold us back from releasing the |
Closes #11676
Adds a codemod that applies the
@unmask
directive to all named fragments in a file. This works for:gql
(orgraphql
) tagged template literalsgraphql
(orgql
) functions.graphql
or.gql
filesTo run the codemod, use the following:
By default this adds the
@unmask
directive with no arguments. To add it in migrate mode, use the--mode migrate
option in the CLI:You can customize the tag name with the
--tag
option, or use it to only apply to a specific tag name. This defaults to bothgql
andgraphql
tags when not provided.Pass
--tag
multiple times to parse more than one tag name.