@apollo/client 4.2.1 → 4.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @apollo/client
2
2
 
3
+ ## 4.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#13184](https://github.com/apollographql/apollo-client/pull/13184) [`c207b88`](https://github.com/apollographql/apollo-client/commit/c207b886026114943dc7f5c85e997a1938e74cfe) Thanks [@audrius-savickas](https://github.com/audrius-savickas)! - Preserve referential equality of masked data on refetch when the result is deeply equal to the previous result.
8
+
3
9
  ## 4.2.1
4
10
 
5
11
  ### Patch Changes
@@ -1326,6 +1326,14 @@ class ObservableQuery {
1326
1326
  result.networkStatus = this.calculateNetworkStatus(result.networkStatus);
1327
1327
  result.loading = (0, utilities_1.isNetworkRequestInFlight)(result.networkStatus);
1328
1328
  result = this.maskResult(result);
1329
+ // Preserve referential equality of masked data when the new masked
1330
+ // result is deeply equal to the previous one. This prevents React hooks
1331
+ // like `useMemo` or `useEffect` from firing unnecessarily.
1332
+ if (previous.result.data !== undefined &&
1333
+ result.data !== previous.result.data &&
1334
+ (0, equality_1.equal)(result.data, previous.result.data)) {
1335
+ result.data = previous.result.data;
1336
+ }
1329
1337
  return { query, variables, result, meta };
1330
1338
  });
1331
1339
  // Reobserve with fetchPolicy effectively set to "cache-first", triggering