diff --git a/.changeset/brown-readers-smash.md b/.changeset/brown-readers-smash.md deleted file mode 100644 index 101b98c38f4..00000000000 --- a/.changeset/brown-readers-smash.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Maintain the existing document if its unchanged by the codemod and move to more naive whitespace formatting diff --git a/.changeset/clean-turkeys-kick.md b/.changeset/clean-turkeys-kick.md deleted file mode 100644 index a5d2e54cabe..00000000000 --- a/.changeset/clean-turkeys-kick.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Fix issue when using `Unmasked` with older versions of TypeScript when used with array fields. diff --git a/.changeset/cold-apes-bow.md b/.changeset/cold-apes-bow.md deleted file mode 100644 index e909a6162a6..00000000000 --- a/.changeset/cold-apes-bow.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": minor ---- - -Promote to 3.12.0-rc.0 diff --git a/.changeset/early-bobcats-eat.md b/.changeset/early-bobcats-eat.md deleted file mode 100644 index 64907a4bda9..00000000000 --- a/.changeset/early-bobcats-eat.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Prevent field accessor warnings when using `@unmask(mode: "migrate")` on objects that are passed into `cache.identify`. diff --git a/.changeset/flat-beans-knock.md b/.changeset/flat-beans-knock.md deleted file mode 100644 index dcfdcea82ec..00000000000 --- a/.changeset/flat-beans-knock.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -"@apollo/client": patch ---- - -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 --parser tsx path/to/app/ -``` - -To customize the tag used to search for GraphQL operations, use the `--tag` option. By default the codemod looks for `gql` and `graphql` tags. - -To apply the directive in migrate mode in order to receive runtime warnings on potentially masked fields, use the `--mode migrate` option. - -For more information on the options that can be used with `jscodeshift`, check out the [`jscodeshift` documentation](https://github.com/facebook/jscodeshift). diff --git a/.changeset/gorgeous-zebras-confess.md b/.changeset/gorgeous-zebras-confess.md deleted file mode 100644 index 3d7e4265edd..00000000000 --- a/.changeset/gorgeous-zebras-confess.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Fix issue where data went missing when an unmasked fragment in migrate mode selected fields that the parent did not. diff --git a/.changeset/happy-months-happen.md b/.changeset/happy-months-happen.md deleted file mode 100644 index 50203b1387f..00000000000 --- a/.changeset/happy-months-happen.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Data masking types: handle overlapping nested array types and fragments on interface types. diff --git a/.changeset/itchy-penguins-worry.md b/.changeset/itchy-penguins-worry.md deleted file mode 100644 index 4459d490662..00000000000 --- a/.changeset/itchy-penguins-worry.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Fix issue where masked data would sometimes get returned when the field was part of a child fragment from a fragment unmasked by the parent query. diff --git a/.changeset/kind-toys-tie.md b/.changeset/kind-toys-tie.md deleted file mode 100644 index 54cda460ac2..00000000000 --- a/.changeset/kind-toys-tie.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Warn when using data masking with "no-cache" operations. diff --git a/.changeset/long-zoos-ring.md b/.changeset/long-zoos-ring.md deleted file mode 100644 index 6c7d5072a1a..00000000000 --- a/.changeset/long-zoos-ring.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": minor ---- - -Allow `null` as a valid `from` value in `useFragment`. diff --git a/.changeset/mean-bottles-travel.md b/.changeset/mean-bottles-travel.md deleted file mode 100644 index a2e1fd300d2..00000000000 --- a/.changeset/mean-bottles-travel.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Fix issue where the warning emitted by `@unmask(mode: "migrate")` would trigger unnecessarily when the fragment was used alongside a masked fragment inside an inline fragment. diff --git a/.changeset/nasty-camels-pay.md b/.changeset/nasty-camels-pay.md deleted file mode 100644 index be446b1a1f0..00000000000 --- a/.changeset/nasty-camels-pay.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -"@apollo/client": minor ---- - -Introduces data masking into Apollo Client. Data masking allows components to access only the data they asked for through GraphQL fragments. This prevents coupling between components that might otherwise implicitly rely on fields not requested by the component. Data masking also provides the benefit that masked fields only rerender components that ask for the field. - -To enable data masking in Apollo Client, set the `dataMasking` option to `true`. - -```ts -new ApolloClient({ - dataMasking: true, - // ... other options -}) -``` - -You can selectively disable data masking using the `@unmask` directive. Apply this to any named fragment to receive all fields requested by the fragment. - -```graphql -query { - user { - id - ...UserFields @unmask - } -} -``` - -To help with migration, use the `@unmask` migrate mode which will add warnings when accessing fields that would otherwise be masked. - -```graphql -query { - user { - id - ...UserFields @unmask(mode: "migrate") - } -} -``` diff --git a/.changeset/nervous-owls-hear.md b/.changeset/nervous-owls-hear.md deleted file mode 100644 index 760fc8c2c0f..00000000000 --- a/.changeset/nervous-owls-hear.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Fix error when combining `@unmask` and `@defer` directives on a fragment spread when data masking is enabled. diff --git a/.changeset/nice-countries-share.md b/.changeset/nice-countries-share.md deleted file mode 100644 index 0af3ec25287..00000000000 --- a/.changeset/nice-countries-share.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Fix error thrown when applying unmask migrate mode warnings on interface types with selection sets that contain inline fragment conditions. diff --git a/.changeset/perfect-jobs-flow.md b/.changeset/perfect-jobs-flow.md deleted file mode 100644 index 594b7c26ba5..00000000000 --- a/.changeset/perfect-jobs-flow.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Add a helper that will skip the TS unmasking alorithm when no fragments are present on type level diff --git a/.changeset/slimy-points-end.md b/.changeset/slimy-points-end.md deleted file mode 100644 index e7147ccdd35..00000000000 --- a/.changeset/slimy-points-end.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Ensure documents unchanged by the codemod are left untouched. diff --git a/.changeset/small-bears-confess.md b/.changeset/small-bears-confess.md deleted file mode 100644 index d062a652746..00000000000 --- a/.changeset/small-bears-confess.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Ensure `null` is retained in nullable types when unmasking a type with the `Unmasked` helper type. diff --git a/.changeset/wicked-pans-appear.md b/.changeset/wicked-pans-appear.md deleted file mode 100644 index fc4a3b5eb6d..00000000000 --- a/.changeset/wicked-pans-appear.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Fix issue that threw errors when masking partial data with `@unmask(mode: "migrate")`. diff --git a/CHANGELOG.md b/CHANGELOG.md index ac7fad92895..d173722019b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,65 @@ # @apollo/client +## 3.12.0 + +### Minor Changes + +#### Data masking 🎭 + +- [#12042](https://github.com/apollographql/apollo-client/pull/12042) [`1c0ecbf`](https://github.com/apollographql/apollo-client/commit/1c0ecbf3c0454056853dd3dcb493dfd5fa1a96b1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Introduces data masking in Apollo Client. + + Data masking enforces that only the fields requested by the query or fragment is available to that component. Data masking is best paired with [colocated fragments](https://www.apollographql.com/docs/react/data/fragments#colocating-fragments). + + To enable data masking in Apollo Client, set the `dataMasking` option to `true`. + + ```ts + new ApolloClient({ + dataMasking: true, + // ... other options + }); + ``` + + For detailed information on data masking, including how to incrementally adopt it in an existing applications, see the [data masking documentation](https://www.apollographql.com/docs/react/data/fragments#data-masking). + +- [#12131](https://github.com/apollographql/apollo-client/pull/12131) [`21c3f08`](https://github.com/apollographql/apollo-client/commit/21c3f083013445707b7b50ae6390318bc568d0f5) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Allow `null` as a valid `from` value in `useFragment`. + +
+

More Patch Changes

+ +- [#12126](https://github.com/apollographql/apollo-client/pull/12126) [`d10d702`](https://github.com/apollographql/apollo-client/commit/d10d702ee9bd4d1d1dee2551821140f2c49d5c0c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Maintain the existing document if its unchanged by the codemod and move to more naive whitespace formatting + +- [#12150](https://github.com/apollographql/apollo-client/pull/12150) [`9ed1e1e`](https://github.com/apollographql/apollo-client/commit/9ed1e1ef02b28445614fed4f5c141a289ac32d66) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue when using `Unmasked` with older versions of TypeScript when used with array fields. + +- [#12116](https://github.com/apollographql/apollo-client/pull/12116) [`8ae6e4e`](https://github.com/apollographql/apollo-client/commit/8ae6e4e5cec296c3910fdffb0ce51a0f5f06c5d3) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Prevent field accessor warnings when using `@unmask(mode: "migrate")` on objects that are passed into `cache.identify`. + +- [#12120](https://github.com/apollographql/apollo-client/pull/12120) [`6a98e76`](https://github.com/apollographql/apollo-client/commit/6a98e76af5c800a91a748c498611b55c33e02c68) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Provide a codemod that applies `@unmask` to all named fragments for all operations and fragments. + + Learn how to use the codemod in the [incremental adoption documentation](https://www.apollographql.com/docs/react/data/fragments#incremental-adoption-in-an-existing-application). + +- [#12134](https://github.com/apollographql/apollo-client/pull/12134) [`cfaf4ef`](https://github.com/apollographql/apollo-client/commit/cfaf4efc6dea56ae46a5b5199d8ed9414b0f17d8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue where data went missing when an unmasked fragment in migrate mode selected fields that the parent did not. + +- [#12154](https://github.com/apollographql/apollo-client/pull/12154) [`d933def`](https://github.com/apollographql/apollo-client/commit/d933def986d476cd64321059299ab15031297f04) Thanks [@phryneas](https://github.com/phryneas)! - Data masking types: handle overlapping nested array types and fragments on interface types. + +- [#12139](https://github.com/apollographql/apollo-client/pull/12139) [`5a53e15`](https://github.com/apollographql/apollo-client/commit/5a53e15e713e5eb2ebc9216615ea1a845fad2685) Thanks [@phryneas](https://github.com/phryneas)! - Fix issue where masked data would sometimes get returned when the field was part of a child fragment from a fragment unmasked by the parent query. + +- [#12123](https://github.com/apollographql/apollo-client/pull/12123) [`8422a30`](https://github.com/apollographql/apollo-client/commit/8422a305eff861fc8f953731e92c860f555bd99a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Warn when using data masking with "no-cache" operations. + +- [#12139](https://github.com/apollographql/apollo-client/pull/12139) [`5a53e15`](https://github.com/apollographql/apollo-client/commit/5a53e15e713e5eb2ebc9216615ea1a845fad2685) Thanks [@phryneas](https://github.com/phryneas)! - Fix issue where the warning emitted by `@unmask(mode: "migrate")` would trigger unnecessarily when the fragment was used alongside a masked fragment inside an inline fragment. + +- [#12114](https://github.com/apollographql/apollo-client/pull/12114) [`1d4ce00`](https://github.com/apollographql/apollo-client/commit/1d4ce0034395147445165022f7d23f42ff638d8a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix error when combining `@unmask` and `@defer` directives on a fragment spread when data masking is enabled. + +- [#12130](https://github.com/apollographql/apollo-client/pull/12130) [`1e7d009`](https://github.com/apollographql/apollo-client/commit/1e7d009e4a52949dab0065f3219dfe148837531e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix error thrown when applying unmask migrate mode warnings on interface types with selection sets that contain inline fragment conditions. + +- [#12152](https://github.com/apollographql/apollo-client/pull/12152) [`78137ec`](https://github.com/apollographql/apollo-client/commit/78137eccba90b80dd29bd8e1423b49ebe51ef8df) Thanks [@phryneas](https://github.com/phryneas)! - Add a helper that will skip the TS unmasking alorithm when no fragments are present on type level + +- [#12126](https://github.com/apollographql/apollo-client/pull/12126) [`d10d702`](https://github.com/apollographql/apollo-client/commit/d10d702ee9bd4d1d1dee2551821140f2c49d5c0c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure documents unchanged by the codemod are left untouched. + +- [#12133](https://github.com/apollographql/apollo-client/pull/12133) [`a6ece37`](https://github.com/apollographql/apollo-client/commit/a6ece375119ce12c19749471c55b0059843a7217) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure `null` is retained in nullable types when unmasking a type with the `Unmasked` helper type. + +- [#12139](https://github.com/apollographql/apollo-client/pull/12139) [`5a53e15`](https://github.com/apollographql/apollo-client/commit/5a53e15e713e5eb2ebc9216615ea1a845fad2685) Thanks [@phryneas](https://github.com/phryneas)! - Fix issue that threw errors when masking partial data with `@unmask(mode: "migrate")`. + +
+ ## 3.12.0-rc.4 ### Patch Changes diff --git a/package-lock.json b/package-lock.json index 478f7990666..387e6724bf0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@apollo/client", - "version": "3.11.10", + "version": "3.12.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@apollo/client", - "version": "3.11.10", + "version": "3.12.0", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 66f5253d4d6..45890e70f2c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@apollo/client", - "version": "3.11.10", + "version": "3.12.0", "description": "A fully-featured caching GraphQL client.", "private": true, "keywords": [