Skip to content

Commit

Permalink
docs: explain masking incompatibility (#12255)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meschreiber authored Jan 8, 2025
1 parent bab8067 commit df9d0db
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions docs/source/data/fragments.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1138,11 +1138,11 @@ const config: CodegenConfig = {
Support for the `@unmask` directive was introduced with `@graphql-codegen/client-preset` [v4.5.1](https://github.com/dotansimha/graphql-code-generator/releases/tag/release-1732308151614)
</Note>
Add the following configuration to your GraphQL Codegen config.
You can't use the `client-preset` [Fragment Masking](https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#fragment-masking) and Apollo Client's data masking features simultaneously.
The incompatibility between the features is in runtime behavior only.
Apollo's data masking uses the same type output generated by CodeGen's Fragment Masking feature.
<Caution>
The [Fragment Masking](https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#fragment-masking) feature in the client preset is incompatible with Apollo Client's data masking feature. You need to [turn off Fragment Masking](https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#how-to-disable-fragment-masking) in your configuration (included below). If you use the [generated `useFragment` function](https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#the-usefragment-helper), you must use Apollo Client's [`useFragment`](#usefragment) hook instead.
</Caution>
If you've [enabled data masking](#enabling-data-masking) in Apollo Client, make sure you [turn off Fragment Masking](https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#how-to-disable-fragment-masking) in your GraphQL Codegen config, along with these additions:
```ts title="codegen.ts"
const config: CodegenConfig = {
Expand All @@ -1166,6 +1166,8 @@ const config: CodegenConfig = {
}
```
Additionally, if you use the [generated `useFragment` function](https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#the-usefragment-helper), you must use Apollo Client's [`useFragment`](#usefragment) hook instead.
#### Opting in to use masked types
<Note>
Expand Down

0 comments on commit df9d0db

Please sign in to comment.