PackageTrack

npm · #4032

@apollo/client

4.2.12apollographql/apollo-client

A fully-featured caching GraphQL client.

Release timeline

723 releases since 2019
2020202120222023202420252026

Releases

  1. 3.13.64 Apr 2025
    Release notes3 sources agree

    Patch Changes

    • #12285 cdc55ff Thanks @phryneas! - keep ObservableQuery created by useQuery non-active before it is first subscribed
    Open source →
  2. 3.13.520 Mar 2025
    Release notes3 sources agree

    Patch Changes

    • #12461 12c8d06 Thanks @jerelmiller! - Fix an issue where a cache-first query would return the result for previous variables when a cache update is issued after simultaneously changing variables and skipping the query.
    Open source →
  3. 3.13.410 Mar 2025
    Release notes3 sources agree

    Patch Changes

    • #12420 fee9368 Thanks @jorenbroekema! - Use import star from rehackt to prevent issues with importing named exports from external CJS modules.
    Open source →
  4. 3.13.37 Mar 2025
    Release notes3 sources agree

    Patch Changes

    • #12362 f6d387c Thanks @jerelmiller! - Fixes an issue where calling observableQuery.getCurrentResult() when the errorPolicy was set to all would return the networkStatus as NetworkStatus.ready when there were errors returned in the result. This has been corrected to report NetworkStatus.error.

      This bug also affected the useQuery and useLazyQuery hooks and may affect you if you check for networkStatus in your component.

    Open source →
  5. 3.13.26 Mar 2025
    Release notes3 sources agree

    Patch Changes

    • #12409 6aa2f3e Thanks @phryneas! - To mitigate problems when Apollo Client ends up more than once in the bundle, some unique symbols were converted into Symbol.for calls.

    • #12392 644bb26 Thanks @Joja81! - Fixes an issue where the DeepOmit type would turn optional properties into required properties. This should only affect you if you were using the omitDeep or stripTypename utilities exported by Apollo Client.

    • #12404 4332b88 Thanks @jerelmiller! - Show NaN rather than converting to null in debug messages from MockLink for unmatched variables values.

    Open source →
  6. 3.13.114 Feb 2025
    Release notes3 sources agree

    Patch Changes

    Open source →
  7. 3.13.013 Feb 2025
    Release notes

    Apollo Client v3.13.0 introduces a new hook, useSuspenseFragment, as a drop-in replacement for useFragment in apps that are using React Suspense. This is the “last” React hook we are introducing in 3.x - we think this rounds out the “big concepts” in our React Suspense and GraphQL fragment story. See the docs for information on this and our other Suspense-supporting hooks. There are some TypeScript quality-of-life improvements shipped in this release for observableQuery.updateQuery and subscribeToMore. Additionally, the return type of updateQuery now includes undefined to allow an early exit from updates. This was always supported at runtime, but was missed on the TypeScript side. On the runtime side, we’ve fixed query deduplication behavior for multipart responses and corrected the error handling in useMutation callbacks. onCompleted and onError in useQuery and useLazyQuery have been deprecated for multiple reasons. See below for full details 👀

    Minor Changes

    • #12066 c01da5d Thanks @jerelmiller! - Adds a new useSuspenseFragment hook.

      useSuspenseFragment suspends until data is complete. It is a drop-in replacement for useFragment when you prefer to use Suspense to control the loading state of a fragment. See the documentation for more details.

    • #12174 ba5cc33 Thanks @jerelmiller! - Ensure errors thrown in the onCompleted callback from useMutation don't call onError.

    • #12340 716d02e Thanks @phryneas! - Deprecate the onCompleted and onError callbacks of useQuery and useLazyQuery. For more context, please see the related issue on GitHub.

    • #12276 670f112 Thanks @Cellule! - Provide a more type-safe option for the previous data value passed to observableQuery.updateQuery. Using it could result in crashes at runtime as this callback could be called with partial data even though its type reported the value as a complete result.

      The updateQuery callback function is now called with a new type-safe previousData property and a new complete property in the 2nd argument that determines whether previousData is a complete or partial result.

      As a result of this change, it is recommended to use the previousData property passed to the 2nd argument of the callback rather than using the previous data value from the first argument since that value is not type-safe. The first argument is now deprecated and will be removed in a future version of Apollo Client.

      observableQuery.updateQuery(
        (unsafePreviousData, { previousData, complete }) => {
          previousData;
          // ^? TData | DeepPartial<TData> | undefined
      
          if (complete) {
            previousData;
            // ^? TData
          } else {
            previousData;
            // ^? DeepPartial<TData> | undefined
          }
        }
      );
      
    • #12174 ba5cc33 Thanks @jerelmiller! - Reject the mutation promise if errors are thrown in the onCompleted callback of useMutation.

    Patch Changes

    • #12276 670f112 Thanks @Cellule! - Fix the return type of the updateQuery function to allow for undefined. updateQuery had the ability to bail out of the update by returning a falsey value, but the return type enforced a query value.

      observableQuery.updateQuery(
        (unsafePreviousData, { previousData, complete }) => {
          if (!complete) {
            // Bail out of the update by returning early
            return;
          }
      
          // ...
        }
      );
      
    • #12296 2422df2 Thanks @Cellule! - Deprecate option ignoreResults in useMutation. Once this option is removed, existing code still using it might see increase in re-renders. If you don't want to synchronize your component state with the mutation, please use useApolloClient to get your ApolloClient instance and call client.mutate directly.

    • #12338 67c16c9 Thanks @phryneas! - In case of a multipart response (e.g. with @defer), query deduplication will now keep going until the final chunk has been received.

    • #12276 670f112 Thanks @Cellule! - Fix the type of the variables property passed as the 2nd argument to the subscribeToMore callback. This was previously reported as the variables type for the subscription itself, but is now properly typed as the query variables.

    Open source →
    Additional notes2 sources agree

    Minor Changes

    • #12066 c01da5d Thanks @jerelmiller! - Adds a new useSuspenseFragment hook.

      useSuspenseFragment suspends until data is complete. It is a drop-in replacement for useFragment when you prefer to use Suspense to control the loading state of a fragment. See the documentation for more details.

    • #12174 ba5cc33 Thanks @jerelmiller! - Ensure errors thrown in the onCompleted callback from useMutation don't call onError.

    • #12340 716d02e Thanks @phryneas! - Deprecate the onCompleted and onError callbacks of useQuery and useLazyQuery. For more context, please see the related issue on GitHub.

    • #12276 670f112 Thanks @Cellule! - Provide a more type-safe option for the previous data value passed to observableQuery.updateQuery. Using it could result in crashes at runtime as this callback could be called with partial data even though its type reported the value as a complete result.

      The updateQuery callback function is now called with a new type-safe previousData property and a new complete property in the 2nd argument that determines whether previousData is a complete or partial result.

      As a result of this change, it is recommended to use the previousData property passed to the 2nd argument of the callback rather than using the previous data value from the first argument since that value is not type-safe. The first argument is now deprecated and will be removed in a future version of Apollo Client.

      observableQuery.updateQuery(
        (unsafePreviousData, { previousData, complete }) => {
          previousData;
          // ^? TData | DeepPartial<TData> | undefined
      
          if (complete) {
            previousData;
            // ^? TData
          } else {
            previousData;
            // ^? DeepPartial<TData> | undefined
          }
        }
      );
      
    • #12174 ba5cc33 Thanks @jerelmiller! - Reject the mutation promise if errors are thrown in the onCompleted callback of useMutation.

    Patch Changes

    • #12276 670f112 Thanks @Cellule! - Fix the return type of the updateQuery function to allow for undefined. updateQuery had the ability to bail out of the update by returning a falsey value, but the return type enforced a query value.

      observableQuery.updateQuery(
        (unsafePreviousData, { previousData, complete }) => {
          if (!complete) {
            // Bail out of the update by returning early
            return;
          }
      
          // ...
        }
      );
      
    • #12296 2422df2 Thanks @Cellule! - Deprecate option ignoreResults in useMutation. Once this option is removed, existing code still using it might see increase in re-renders. If you don't want to synchronize your component state with the mutation, please use useApolloClient to get your ApolloClient instance and call client.mutate directly.

    • #12338 67c16c9 Thanks @phryneas! - In case of a multipart response (e.g. with @defer), query deduplication will now keep going until the final chunk has been received.

    • #12276 670f112 Thanks @Cellule! - Fix the type of the variables property passed as the 2nd argument to the subscribeToMore callback. This was previously reported as the variables type for the subscription itself, but is now properly typed as the query variables.

    Open source →
  8. 3.13.0-rc.07 Feb 2025pre-release
    Release notes3 sources agree

    Minor Changes

    • #12066 c01da5d Thanks @jerelmiller! - Adds a new useSuspenseFragment hook.

      useSuspenseFragment suspends until data is complete. It is a drop-in replacement for useFragment when you prefer to use Suspense to control the loading state of a fragment.

    • #12174 ba5cc33 Thanks @jerelmiller! - Ensure errors thrown in the onCompleted callback from useMutation don't call onError.

    • #12340 716d02e Thanks @phryneas! - Deprecate the onCompleted and onError callbacks of useQuery and useLazyQuery. For more context, please see the related issue on GitHub.

    • #12276 670f112 Thanks @Cellule! - Provide a more type-safe option for the previous data value passed to observableQuery.updateQuery. Using it could result in crashes at runtime as this callback could be called with partial data even though its type reported the value as a complete result.

      The updateQuery callback function is now called with a new type-safe previousData property and a new complete property in the 2nd argument that determines whether previousData is a complete or partial result.

      As a result of this change, it is recommended to use the previousData property passed to the 2nd argument of the callback rather than using the previous data value from the first argument since that value is not type-safe. The first argument is now deprecated and will be removed in a future version of Apollo Client.

      observableQuery.updateQuery(
        (unsafePreviousData, { previousData, complete }) => {
          previousData;
          // ^? TData | DeepPartial<TData> | undefined
      
          if (complete) {
            previousData;
            // ^? TData
          } else {
            previousData;
            // ^? DeepPartial<TData> | undefined
          }
        }
      );
      
    • #12174 ba5cc33 Thanks @jerelmiller! - Reject the mutation promise if errors are thrown in the onCompleted callback of useMutation.

    Patch Changes

    • #12276 670f112 Thanks @Cellule! - Fix the return type of the updateQuery function to allow for undefined. updateQuery had the ability to bail out of the update by returning a falsey value, but the return type enforced a query value.

      observableQuery.updateQuery(
        (unsafePreviousData, { previousData, complete }) => {
          if (!complete) {
            // Bail out of the update by returning early
            return;
          }
      
          // ...
        }
      );
      
    • #12296 2422df2 Thanks @Cellule! - Deprecate option ignoreResults in useMutation. Once this option is removed, existing code still using it might see increase in re-renders. If you don't want to synchronize your component state with the mutation, please use useApolloClient to get your ApolloClient instance and call client.mutate directly.

    • #12338 67c16c9 Thanks @phryneas! - In case of a multipart response (e.g. with @defer), query deduplication will now keep going until the final chunk has been received.

    • #12276 670f112 Thanks @Cellule! - Fix the type of the variables property passed as the 2nd argument to the subscribeToMore updateQuery callback. This was previously reported as the variables type for the subscription itself, but is now properly typed as the query variables.

    Open source →
  9. 3.12.117 Feb 2025
    Release notes3 sources agree

    Patch Changes

    • #12351 3da908b Thanks @jerelmiller! - Fixes an issue where the wrong networkStatus and loading value was emitted from observableQuery when calling fetchMore with a no-cache fetch policy. The networkStatus now properly reports as ready and loading as false after the result is returned.

    • #12354 a24ef94 Thanks @phryneas! - Fix missing main.d.cts file

    Open source →
  10. 3.12.106 Feb 2025
    Release notes3 sources agree

    Patch Changes

    • #12341 f2bb0b9 Thanks @phryneas! - useReadQuery/useQueryRefHandlers: Fix a "hook order" warning that might be emitted in React 19 dev mode.

    • #12342 219b26b Thanks @phryneas! - Add graphql-ws ^6.0.3 as a valid peerDependency

    Open source →
  11. 3.12.93 Feb 2025
    Release notes3 sources agree

    Patch Changes

    • #12321 daa4f33 Thanks @jerelmiller! - Fix type of extensions in protocolErrors for ApolloError and the onError link. According to the multipart HTTP subscription protocol, fatal tranport errors follow the GraphQL error format which require extensions to be a map as its value instead of an array.

    • #12318 b17968b Thanks @jerelmiller! - Allow RetryLink to retry an operation when fatal transport-level errors are emitted from multipart subscriptions.

      const retryLink = new RetryLink({
        attempts: (count, operation, error) => {
          if (error instanceof ApolloError) {
            // errors available on the `protocolErrors` field in `ApolloError`
            console.log(error.protocolErrors);
          }
      
          return true;
        },
      });
      
    Open source →
  12. 3.12.827 Jan 2025
    Release notes3 sources agree

    Patch Changes

    • #12292 3abd944 Thanks @phryneas! - Remove unused dependency response-iterator

    • #12287 bf313a3 Thanks @phryneas! - Fixes an issue where client.watchFragment/useFragment with @includes crashes when a separate cache update writes to the conditionally included fields.

    Open source →
  13. 3.12.722 Jan 2025
    Release notes3 sources agree

    Patch Changes

    • #12281 d638ec3 Thanks @jerelmiller! - Make fatal tranport-level errors from multipart subscriptions available to the error link with the protocolErrors property.

      const errorLink = onError(({ protocolErrors }) => {
        if (protocolErrors) {
          console.log(protocolErrors);
        }
      });
      
    • #12281 d638ec3 Thanks @jerelmiller! - Fix the array type for the errors field on the ApolloPayloadResult type. This type was always in the shape of the GraphQL error format, per the multipart subscriptions protocol and never a plain string or a JavaScript error object.

    Open source →
  14. 3.12.614 Jan 2025
    Release notes3 sources agree

    Patch Changes

    • #12267 d57429d Thanks @jerelmiller! - Maintain the TData type when used with Unmasked when TData is not a masked type generated from GraphQL Codegen.

    • #12270 3601246 Thanks @jerelmiller! - Fix handling of tagged/branded primitive types when used as scalar values with Unmasked.

    Open source →
  15. 3.12.59 Jan 2025
    Release notes

    Patch Changes

    • #12252 cb9cd4e Thanks @jerelmiller! - Changes the default behavior of the MaybeMasked type to preserve types unless otherwise specified. This change makes it easier to upgrade from older versions of the client where types could have unexpectedly changed in the application due to the default of trying to unwrap types into unmasked types. This change also fixes the compilation performance regression experienced when simply upgrading the client since types are now preserved by default.

      A new mode option has now been introduced to allow for the old behavior. See the next section on migrating if you wish to maintain the old default behavior after upgrading to this version.

      Migrating from <= v3.12.4

      If you've adopted data masking and have opted in to using masked types by setting the enabled property to true, you can remove this configuration entirely:

      -declare module "@apollo/client" {
      -  interface DataMasking {
      -    mode: "unmask"
      -  }
      -}
      

      If you prefer to specify the behavior explicitly, change the property from enabled: true, to mode: "preserveTypes":

      declare module "@apollo/client" {
        interface DataMasking {
      -    enabled: true
      +    mode: "preserveTypes"
        }
      }
      

      If you rely on the default behavior in 3.12.4 or below and would like to continue to use unmasked types by default, set the mode to unmask:

      declare module "@apollo/client" {
        interface DataMasking {
          mode: "unmask";
        }
      }
      
    Open source →
    Additional notes2 sources agree

    Patch Changes

    • #12252 cb9cd4e Thanks @jerelmiller! - Changes the default behavior of the MaybeMasked type to preserve types unless otherwise specified. This change makes it easier to upgrade from older versions of the client where types could have unexpectedly changed in the application due to the default of trying to unwrap types into unmasked types. This change also fixes the compilation performance regression experienced when simply upgrading the client since types are now preserved by default.

      A new mode option has now been introduced to allow for the old behavior. See the next section on migrating if you wish to maintain the old default behavior after upgrading to this version.

      Migrating from <= v3.12.4

      If you've adopted data masking and have opted in to using masked types by setting the enabled property to true, you can remove this configuration entirely:

      -declare module "@apollo/client" {
      -  interface DataMasking {
      -    mode: "unmask"
      -  }
      -}
      

      If you prefer to specify the behavior explicitly, change the property from enabled: true, to mode: "preserveTypes":

      declare module "@apollo/client" {
        interface DataMasking {
      -    enabled: true
      +    mode: "preserveTypes"
        }
      }
      

      If you rely on the default behavior in 3.12.4 or below and would like to continue to use unmasked types by default, set the mode to unmask:

      declare module "@apollo/client" {
        interface DataMasking {
          mode: "unmask";
        }
      }
      
    Open source →
  16. 3.12.419 Dec 2024
    Release notes3 sources agree

    Patch Changes

    • #12236 4334d30 Thanks @charpeni! - Fix an issue with refetchQueries where comparing DocumentNodes internally by references could lead to an unknown query, even though the DocumentNode was indeed an active query—with a different reference.
    Open source →
  17. 3.12.312 Dec 2024
    Release notes3 sources agree

    Patch Changes

    Open source →
  18. 3.12.25 Dec 2024
    Release notes3 sources agree

    Patch Changes

    Open source →
  19. 3.12.15 Dec 2024
    Release notes3 sources agree

    Patch Changes

    Open source →
  20. 3.12.04 Dec 2024
    Release notes3 sources agree

    Minor Changes

    Data masking 🎭

    • #12042 1c0ecbf Thanks @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.

      To enable data masking in Apollo Client, set the dataMasking option to true.

      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.

    • #12131 21c3f08 Thanks @jerelmiller! - Allow null as a valid from value in useFragment.

    <details open> <summary><h3>More Patch Changes</h3></summary>

    • #12126 d10d702 Thanks @jerelmiller! - Maintain the existing document if its unchanged by the codemod and move to more naive whitespace formatting

    • #12150 9ed1e1e Thanks @jerelmiller! - Fix issue when using Unmasked with older versions of TypeScript when used with array fields.

    • #12116 8ae6e4e Thanks @jerelmiller! - Prevent field accessor warnings when using @unmask(mode: "migrate") on objects that are passed into cache.identify.

    • #12120 6a98e76 Thanks @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.

    • #12134 cfaf4ef Thanks @jerelmiller! - Fix issue where data went missing when an unmasked fragment in migrate mode selected fields that the parent did not.

    • #12154 d933def Thanks @phryneas! - Data masking types: handle overlapping nested array types and fragments on interface types.

    • #12139 5a53e15 Thanks @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 8422a30 Thanks @jerelmiller! - Warn when using data masking with "no-cache" operations.

    • #12139 5a53e15 Thanks @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 1d4ce00 Thanks @jerelmiller! - Fix error when combining @unmask and @defer directives on a fragment spread when data masking is enabled.

    • #12130 1e7d009 Thanks @jerelmiller! - Fix error thrown when applying unmask migrate mode warnings on interface types with selection sets that contain inline fragment conditions.

    • #12152 78137ec Thanks @phryneas! - Add a helper that will skip the TS unmasking alorithm when no fragments are present on type level

    • #12126 d10d702 Thanks @jerelmiller! - Ensure documents unchanged by the codemod are left untouched.

    • #12133 a6ece37 Thanks @jerelmiller! - Ensure null is retained in nullable types when unmasking a type with the Unmasked helper type.

    • #12139 5a53e15 Thanks @phryneas! - Fix issue that threw errors when masking partial data with @unmask(mode: "migrate").

    </details>

    Open source →
  21. 3.12.0-rc.427 Nov 2024pre-release
    Release notes3 sources agree

    Patch Changes

    • #12154 d933def Thanks @phryneas! - Data masking types: handle overlapping nested array types and fragments on interface types.
    Open source →
  22. 3.12.0-rc.320 Nov 2024pre-release
    Release notes3 sources agree

    Patch Changes

    • #12150 9ed1e1e Thanks @jerelmiller! - Fix issue when using Unmasked with older versions of TypeScript when used with array fields.

    • #12152 78137ec Thanks @phryneas! - Add a helper that will skip the TS unmasking alorithm when no fragments are present on type level

    Open source →
  23. 3.12.0-rc.219 Nov 2024pre-release
    Release notes3 sources agree

    Patch Changes

    • #12139 5a53e15 Thanks @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.

    • #12139 5a53e15 Thanks @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.

    • #12139 5a53e15 Thanks @phryneas! - Fix issue that threw errors when masking partial data with @unmask(mode: "migrate").

    Open source →
  24. 3.12.0-rc.115 Nov 2024pre-release
    Release notes3 sources agree

    Minor Changes

    Patch Changes

    • #12126 d10d702 Thanks @jerelmiller! - Maintain the existing document if its unchanged by the codemod and move to more naive whitespace formatting

    • #12134 cfaf4ef Thanks @jerelmiller! - Fix issue where data went missing when an unmasked fragment in migrate mode selected fields that the parent did not.

    • #12130 1e7d009 Thanks @jerelmiller! - Fix error thrown when applying unmask migrate mode warnings on interface types with selection sets that contain inline fragment conditions.

    • #12126 d10d702 Thanks @jerelmiller! - Ensure documents unchanged by the codemod are left untouched.

    • #12133 a6ece37 Thanks @jerelmiller! - Ensure null is retained in nullable types when unmasking a type with the Unmasked helper type.

    Open source →
  25. 3.12.0-rc.013 Nov 2024pre-release
    Release notes

    Patch Changes

    • #12116 8ae6e4e Thanks @jerelmiller! - Prevent field accessor warnings when using @unmask(mode: "migrate") on objects that are passed into cache.identify.

    • #12120 6a98e76 Thanks @jerelmiller! - 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.

    • #12121 1085a95 Thanks @jerelmiller! - Warn when using data masking with "no-cache" operations.

    • #12114 1d4ce00 Thanks @jerelmiller! - Fix error when combining @unmask and @defer directives on a fragment spread when data masking is enabled.

    Open source →
    Additional notes2 sources agree

    Patch Changes

    • #12116 8ae6e4e Thanks @jerelmiller! - Prevent field accessor warnings when using @unmask(mode: "migrate") on objects that are passed into cache.identify.

    • #12120 6a98e76 Thanks @jerelmiller! - 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.

    • #12121 1085a95 Thanks @jerelmiller! - Warn when using data masking with "no-cache" operations.

    • #12114 1d4ce00 Thanks @jerelmiller! - Fix error when combining @unmask and @defer directives on a fragment spread when data masking is enabled.

    Open source →
  26. 3.12.0-alpha.01 Oct 2024pre-release
    Release notes3 sources agree

    Minor Changes

    • #12042 1c0ecbf Thanks @jerelmiller! - 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.

      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.

      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.

      query {
        user {
          id
          ...UserFields @unmask(mode: "migrate")
        }
      }
      
    Open source →
  27. 3.11.11-rc.013 Nov 2024pre-releasewithdrawn: Please use version 3.12.0-rc.0 instead

    Nothing published for this version

  28. 3.11.1011 Nov 2024
    Release notes3 sources agree

    Patch Changes

    • #12093 1765668 Thanks @mgmolisani! - Fixed a bug when evaluating the devtools flag with the new syntax devtools.enabled that could result to true when explicitly set to false.
    Open source →
  29. 3.11.97 Nov 2024
    Release notes3 sources agree

    Patch Changes

    • #12110 a3f95c6 Thanks @jerelmiller! - Fix an issue where errors returned from a fetchMore call from a Suspense hook would cause a Suspense boundary to be shown indefinitely.
    Open source →
  30. 3.11.85 Sept 2024
    Release notes3 sources agree

    Patch Changes

    • #12054 35cf186 Thanks @phryneas! - Fixed a bug where incorrect object access in some Safari extensions could cause a crash.
    Open source →
  31. 3.11.74 Sept 2024
    Release notes3 sources agree

    Patch Changes

    • #12052 e471cef Thanks @jerelmiller! - Fixes a regression from where passing an invalid identifier to from in useFragment would result in the warning TypeError: Cannot read properties of undefined (reading '__typename').
    Open source →
  32. 3.11.63 Sept 2024
    Release notes3 sources agree

    Patch Changes

    Open source →
  33. 3.11.528 Aug 2024
    Release notes3 sources agree

    Patch Changes

    Open source →
  34. 3.11.47 Aug 2024
    Release notes3 sources agree

    Patch Changes

    • #11994 41b17e5 Thanks @jerelmiller! - Update the Modifier function type to allow cache.modify to return deeply partial data.

    • #11989 e609156 Thanks @phryneas! - Fix a potential crash when calling clearStore while a query was running.

      Previously, calling client.clearStore() while a query was running had one of these results:

      • useQuery would stay in a loading: true state.
      • useLazyQuery would stay in a loading: true state, but also crash with a "Cannot read property 'data' of undefined" error.

      Now, in both cases, the hook will enter an error state with a networkError, and the promise returned by the useLazyQuery execute function will return a result in an error state.

    • #11994 41b17e5 Thanks @jerelmiller! - Prevent accidental distribution on cache.modify field modifiers when a field is a union type array.

    Open source →
  35. 3.11.35 Aug 2024
    Release notes3 sources agree

    Patch Changes

    • #11984 5db1659 Thanks @jerelmiller! - Fix an issue where multiple fetches with results that returned errors would sometimes set the data property with an errorPolicy of none.

    • #11974 c95848e Thanks @jerelmiller! - Fix an issue where fetchMore would write its result data to the cache when using it with a no-cache fetch policy.

    • #11974 c95848e Thanks @jerelmiller! - Fix an issue where executing fetchMore with a no-cache fetch policy could sometimes result in multiple network requests.

    • #11974 c95848e Thanks @jerelmiller! -

      Potentially disruptive change

      When calling fetchMore with a query that has a no-cache fetch policy, fetchMore will now throw if an updateQuery function is not provided. This provides a mechanism to merge the results from the fetchMore call with the query's previous result.

    Open source →
  36. 3.11.231 Jul 2024
    Release notes3 sources agree

    Patch Changes

    Open source →
  37. 3.11.123 Jul 2024
    Release notes3 sources agree

    Patch Changes

    • #11969 061cab6 Thanks @jerelmiller! - Remove check for window.__APOLLO_CLIENT__ when determining whether to connect to Apollo Client Devtools when connectToDevtools or devtools.enabled is not specified. This now simply checks to see if the application is in development mode.

    • #11971 ecf77f6 Thanks @jerelmiller! - Prevent the setTimeout for suggesting devtools from running in non-browser environments.

    Open source →
  38. 3.11.022 Jul 2024
    Release notes3 sources agree

    Potentially Breaking Fixes

    • #11789 5793301 Thanks @phryneas! - Changes usages of the GraphQLError type to GraphQLFormattedError.

      This was a type bug - these errors were never GraphQLError instances to begin with, and the GraphQLError class has additional properties that can never be correctly rehydrated from a GraphQL result. The correct type to use here is GraphQLFormattedError.

      Similarly, please ensure to use the type FormattedExecutionResult instead of ExecutionResult - the non-"Formatted" versions of these types are for use on the server only, but don't get transported over the network.

    • #11626 228429a Thanks @phryneas! - Call nextFetchPolicy with "variables-changed" even if there is a fetchPolicy specified.

      Previously this would only be called when the current fetchPolicy was equal to the fetchPolicy option or the option was not specified. If you use nextFetchPolicy as a function, expect to see this function called more often.

      Due to this bug, this also meant that the fetchPolicy might be reset to the initial fetchPolicy, even when you specified a nextFetchPolicy function. If you previously relied on this behavior, you will need to update your nextFetchPolicy callback function to implement this resetting behavior.

      As an example, if your code looked like the following:

      useQuery(QUERY, {
        nextFetchPolicy(currentFetchPolicy, info) {
          // your logic here
        }
      );
      

      Update your function to the following to reimplement the resetting behavior:

      useQuery(QUERY, {
        nextFetchPolicy(currentFetchPolicy, info) {
          if (info.reason === 'variables-changed') {
            return info.initialFetchPolicy;
          }
          // your logic here
        }
      );
      

    Minor Changes

    • #11923 d88c7f8 Thanks @jerelmiller! - Add support for subscribeToMore function to useQueryRefHandlers.

    • #11854 3812800 Thanks @jcostello-atlassian! - Support extensions in useSubscription

    • #11923 d88c7f8 Thanks @jerelmiller! - Add support for subscribeToMore function to useLoadableQuery.

    • #11863 98e44f7 Thanks @phryneas! - Reimplement useSubscription to fix rules of React violations.

    • #11869 a69327c Thanks @phryneas! - Rewrite big parts of useQuery and useLazyQuery to be more compliant with the Rules of React and React Compiler

    • #11936 1b23337 Thanks @jerelmiller! - Add the ability to specify a name for the client instance for use with Apollo Client Devtools. This is useful when instantiating multiple clients to identify the client instance more easily. This deprecates the connectToDevtools option in favor of a new devtools configuration.

      new ApolloClient({
        devtools: {
          enabled: true,
          name: "Test Client",
        },
      });
      

      This option is backwards-compatible with connectToDevtools and will be used in the absense of a devtools option.

    • #11923 d88c7f8 Thanks @jerelmiller! - Add support for subscribeToMore function to useBackgroundQuery.

    • #11930 a768575 Thanks @jerelmiller! - Deprecates experimental schema testing utilities introduced in 3.10 in favor of recommending @apollo/graphql-testing-library.

    Patch Changes

    Open source →
  39. 3.11.0-rc.215 Jul 2024pre-release
    Release notes3 sources agree

    Patch Changes

    • #11951 0de03af Thanks @phryneas! - add React 19 RC to peerDependencies

    • #11937 78332be Thanks @phryneas! - createSchemaFetch: simulate serialized errors instead of an ApolloError instance

    • #11944 8f3d7eb Thanks @sneyderdev! - Allow IgnoreModifier to be returned from a optimisticResponse function when inferring from a TypedDocumentNode when used with a generic argument.

    • #11954 4a6e86a Thanks @phryneas! - Document (and deprecate) the previously undocumented errors property on the useQuery QueryResult type.

    Open source →
  40. 3.11.0-rc.110 Jul 2024pre-release
    Release notes3 sources agree

    Patch Changes

    Open source →
  41. 3.11.0-rc.09 Jul 2024pre-release
    Release notes3 sources agree

    Minor Changes

    • #11923 d88c7f8 Thanks @jerelmiller! - Add support for subscribeToMore function to useQueryRefHandlers.

    • #11854 3812800 Thanks @jcostello-atlassian! - Support extensions in useSubscription

    • #11923 d88c7f8 Thanks @jerelmiller! - Add support for subscribeToMore function to useLoadableQuery.

    • #11863 98e44f7 Thanks @phryneas! - Reimplement useSubscription to fix rules of React violations.

    • #11869 a69327c Thanks @phryneas! - Rewrite big parts of useQuery and useLazyQuery to be more compliant with the Rules of React and React Compiler

    • #11936 1b23337 Thanks @jerelmiller! - Add the ability to specify a name for the client instance for use with Apollo Client Devtools. This is useful when instantiating multiple clients to identify the client instance more easily. This deprecates the connectToDevtools option in favor of a new devtools configuration.

      new ApolloClient({
        devtools: {
          enabled: true,
          name: "Test Client",
        },
      });
      

      This option is backwards-compatible with connectToDevtools and will be used in the absense of a devtools option.

    • #11923 d88c7f8 Thanks @jerelmiller! - Add support for subscribeToMore function to useBackgroundQuery.

    • #11789 5793301 Thanks @phryneas! - Changes usages of the GraphQLError type to GraphQLFormattedError.

      This was a type bug - these errors were never GraphQLError instances to begin with, and the GraphQLError class has additional properties that can never be correctly rehydrated from a GraphQL result. The correct type to use here is GraphQLFormattedError.

      Similarly, please ensure to use the type FormattedExecutionResult instead of ExecutionResult - the non-"Formatted" versions of these types are for use on the server only, but don't get transported over the network.

    • #11930 a768575 Thanks @jerelmiller! - Deprecates experimental schema testing utilities introduced in 3.10 in favor of recommending @apollo/graphql-testing-library.

    Patch Changes

    Open source →
  42. 3.10.827 Jun 2024
    Release notes3 sources agree

    Patch Changes

    • #11911 1f0460a Thanks @jerelmiller! - Allow undefined to be returned from a cache.modify modifier function when a generic type argument is used.
    Open source →
  43. 3.10.726 Jun 2024
    Release notes3 sources agree

    Patch Changes

    Open source →
  44. 3.10.621 Jun 2024
    Release notes3 sources agree

    Patch Changes

    Open source →
  45. 3.10.512 Jun 2024
    Release notes3 sources agree

    Patch Changes

    • #11888 7fb7939 Thanks @phryneas! - switch useRenderGuard to an approach not accessing React's internals

    • #11511 6536369 Thanks @phryneas! - useLoadableQuery: ensure that loadQuery is updated if the ApolloClient instance changes

    • #11860 8740f19 Thanks @alessbell! - Fixes #11849 by reevaluating window.fetch each time BatchHttpLink uses it, if not configured via options.fetch. Takes the same approach as PR #8603 which fixed the same issue in HttpLink.

    • #11852 d502a69 Thanks @phryneas! - Fix a bug where calling the useMutation reset function would point the hook to an outdated client reference.

    • #11329 3d164ea Thanks @PaLy! - Fix graphQLErrors in Error Link if networkError.result is an empty string

    • #11852 d502a69 Thanks @phryneas! - Prevent writing to a ref in render in useMutation. As a result, you might encounter problems in the future if you call the mutation's execute function during render. Please note that this was never supported behavior, and we strongly recommend against it.

    • #11848 ad63924 Thanks @phryneas! - Ensure covariant behavior: MockedResponse<X,Y> should be assignable to MockedResponse

    • #11851 45c47be Thanks @phryneas! - Avoid usage of useRef in useInternalState to prevent ref access in render.

    • #11877 634d91a Thanks @phryneas! - Add missing name to tuple member (fix TS5084)

    • #11851 45c47be Thanks @phryneas! - Fix a bug where useLazyQuery would not pick up a client change.

    Open source →
  46. 3.10.415 May 2024
    Release notes3 sources agree

    Patch Changes

    • #11838 8475346 Thanks @alex-kinokon! - Don’t prompt for DevTools installation for browser extension page

    • #11839 6481fe1 Thanks @jerelmiller! - Fix a regression in 3.9.5 where a merge function that returned an incomplete result would not allow the client to refetch in order to fulfill the query.

    • #11844 86984f2 Thanks @jerelmiller! - Honor the @nonreactive directive when using cache.watchFragment or the useFragment hook to avoid rerendering when using these directives.

    • #11824 47ad806 Thanks @phryneas! - Create branded QueryRef type without exposed properties.

      This change deprecates QueryReference in favor of a QueryRef type that doesn't expose any properties. This change also updates preloadQuery to return a new PreloadedQueryRef type, which exposes the toPromise function as it does today. This means that query refs produced by useBackgroundQuery and useLoadableQuery now return QueryRef types that do not have access to a toPromise function, which was never meant to be used in combination with these hooks.

      While we tend to avoid any types of breaking changes in patch releases as this, this change was necessary to support an upcoming version of the React Server Component integration, which needed to omit the toPromise function that would otherwise have broken at runtime. Note that this is a TypeScript-only change. At runtime, toPromise is still present on all queryRefs currently created by this package - but we strongly want to discourage you from accessing it in all cases except for the PreloadedQueryRef use case.

      Migration is as simple as replacing all references to QueryReference with QueryRef, so it should be possible to do this with a search & replace in most code bases:

      -import { QueryReference } from '@apollo/client'
      +import { QueryRef } from '@apollo/client'
      
      - function Component({ queryRef }: { queryRef: QueryReference<TData> }) {
      + function Component({ queryRef }: { queryRef: QueryRef<TData> }) {
        // ...
      }
      
    • #11845 4c5c820 Thanks @jerelmiller! - Remove @nonreactive directives from queries passed to MockLink to ensure they are properly matched.

    • #11837 dff15b1 Thanks @jerelmiller! - Fix an issue where a polled query created in React strict mode may not stop polling after the component unmounts while using the cache-and-network fetch policy.

    Open source →
  47. 3.10.37 May 2024
    Release notes3 sources agree

    Patch Changes

    Open source →
  48. 3.10.23 May 2024
    Release notes3 sources agree

    Patch Changes

    • #11821 2675d3c Thanks @jerelmiller! - Fix a regression where rerendering a component with useBackgroundQuery would recreate the queryRef instance when used with React's strict mode.

    • #11821 2675d3c Thanks @jerelmiller! - Revert the change introduced in 3.9.10 via #11738 that disposed of queryRefs synchronously. This change caused too many issues with strict mode.

    Open source →
  49. 3.10.124 Apr 2024
    Release notes3 sources agree

    Patch Changes

    • #11792 5876c35 Thanks @phryneas! - AutoCleanedCache: only schedule batched cache cleanup if the cache is full (fixes #11790)

    • #11799 1aca7ed Thanks @phryneas! - RenderPromises: use canonicalStringify to serialize variables to ensure query deduplication is properly applied even when variables are specified in a different order.

    • #11803 bf9dd17 Thanks @phryneas! - Update the rehackt dependency to ^0.1.0

    • #11756 60592e9 Thanks @henryqdineen! - Fix operation.setContext() type

    Open source →
  50. 3.10.024 Apr 2024
    Release notes3 sources agree

    Minor Changes

    Patch Changes

    • #11757 9825295 Thanks @phryneas! - Adjust useReadQuery wrapper logic to work with transported objects.

    • #11771 e72cbba Thanks @phryneas! - Wrap useQueryRefHandlers in wrapHook.

    • #11754 80d2ba5 Thanks @alessbell! - Export WatchFragmentOptions and WatchFragmentResult from main entrypoint and fix bug where this wasn't bound to the watchFragment method on ApolloClient.

    Open source →
  51. 3.10.0-rc.115 Apr 2024pre-release
    Release notes3 sources agree

    Minor Changes

    Patch Changes

    • #11757 9825295 Thanks @phryneas! - Adjust useReadQuery wrapper logic to work with transported objects.

    • #11771 e72cbba Thanks @phryneas! - Wrap useQueryRefHandlers in wrapHook.

    • #11754 80d2ba5 Thanks @alessbell! - Export WatchFragmentOptions and WatchFragmentResult from main entrypoint and fix bug where this wasn't bound to the watchFragment method on ApolloClient.

    Open source →
  52. 3.10.0-rc.02 Apr 2024pre-release
    Release notes3 sources agree

    Minor Changes

    Open source →
  53. 3.10.0-alpha.118 Mar 2024pre-release
    Release notes

    Patch Changes

    • #11465 7623da7 Thanks @alessbell! - Add watchFragment method to the cache and expose it on ApolloClient, refactor useFragment using watchFragment.
    Open source →
  54. 3.9.1110 Apr 2024
    Release notes3 sources agree

    Patch Changes

    • #11769 04132af Thanks @jerelmiller! - Fix an issue where using skipToken or the skip option with useSuspenseQuery in React's strict mode would perform a network request.
    Open source →
  55. 3.9.101 Apr 2024
    Release notes3 sources agree

    Patch Changes

    • #11738 b1a5eb8 Thanks @jerelmiller! - Fix an issue where rerendering useBackgroundQuery after the queryRef had been disposed, either via the auto dispose timeout or by unmounting useReadQuery, would cause the queryRef to be recreated potentially resulting in another network request.

    • #11738 b1a5eb8 Thanks @jerelmiller! - Allow queryRefs to be disposed of synchronously when a suspense hook unmounts. This prevents some situations where using a suspense hook with the same query/variables as the disposed queryRef accidentally used the disposed queryRef rather than creating a new instance.

    • #11670 cc5c03b Thanks @phryneas! - Bail out of executeSubSelectedArray calls if the array has 0 elements.

    Open source →
  56. 3.9.922 Mar 2024
    Release notes3 sources agree

    Patch Changes

    • #11696 466ef82 Thanks @PiR1! - Immediately dispose of the queryRef if useBackgroundQuery unmounts before the auto dispose timeout kicks in.
    Open source →
  57. 3.9.820 Mar 2024
    Release notes3 sources agree

    Patch Changes

    • #11706 8619bc7 Thanks @jerelmiller! - Fix issue in all suspense hooks where returning an empty array after calling fetchMore would rerender the component with an empty list.

    • #11694 835d5f3 Thanks @phryneas! - Expose setErrorMessageHandler from @apollo/client/dev entrypoint.

    • #11689 cb8ffe5 Thanks @jerelmiller! - Fix issue where passing a new from option to useFragment would first render with the previous value before rerendering with the correct value.

    • #11713 642092c Thanks @jerelmiller! - Fix issue where setting a default watchQuery option in the ApolloClient constructor could break startTransition when used with suspense hooks.

    Open source →
  58. 3.9.713 Mar 2024
    Release notes3 sources agree

    Patch Changes

    Open source →
  59. 3.9.66 Mar 2024
    Release notes3 sources agree

    Patch Changes

    • #11617 f1d8bc4 Thanks @phryneas! - Allow Apollo Client instance to intercept hook functionality

    • #11638 bf93ada Thanks @jerelmiller! - Fix issue where calling fetchMore from a suspense-enabled hook inside startTransition caused an unnecessary rerender.

    Open source →
  60. 3.9.515 Feb 2024
    Release notes3 sources agree

    Patch Changes

    • #11595 8c20955 Thanks @phryneas! - Bumps the dependency rehackt to 0.0.5

    • #11592 1133469 Thanks @Stephen2! - Strengthen MockedResponse.newData type

    • #11579 1ba2fd9 Thanks @jerelmiller! - Fix issue where partial data is reported to useQuery when using notifyOnNetworkStatusChange after it errors while another overlapping query succeeds.

    • #11579 1ba2fd9 Thanks @jerelmiller! - Fix an issue where a partial cache write for an errored query would result in automatically refetching that query.

    • #11562 65ab695 Thanks @mspiess! - Mocks with an infinite delay no longer require result or error

    Open source →