Packages

@apollo/client

4.3.5 · 19 Oct 2026MIT5.3M / weekRepositoryHomepagenpmAtom feed

Your version

3.5.0

8 Nov 2021Where it was published

3.14.1 is the newest release of 3.x.

In short

14 new6 fixed

Release note

Apollo Client 3.5.0 (2021-11-08)

Improvements

  • Add updateQuery and updateFragment methods to ApolloCache, simplifying common readQuery/writeQuery cache update patterns.
    @wassim-k in #8382

  • Field directives and their arguments can now be included along with field argument names when using field policy keyArgs: [...] notation. For example, if you have a Query.feed field that takes an argument called type and uses a @connection(key:...) directive to keep feed data from different queries separate within the cache, you might configure both using the following InMemoryCache field policy:

    new InMemoryCache({
      typePolicies: {
        Query: {
          fields: {
            feed: {
              keyArgs: ["type", "@connection", ["key"]],
            },
          },
        },
      },
    });

    @benjamn in #8678

  • Report single MissingFieldError instead of a potentially very large MissingFieldError array for incomplete cache reads, improving performance and memory usage.
    @benjamn in #8734

  • When writing results into InMemoryCache, each written object is now identified using policies.identify after traversing the fields of the object (rather than before), simplifying identification and reducing duplicate work. If you have custom keyFields functions, they still receive the raw result object as their first parameter, but the KeyFieldsContext parameter now provides context.storeObject (the StoreObject just processed by processSelectionSet) and context.readField (a helper function for reading fields from context.storeObject and any References it might contain, similar to readField for read, merge, and cache.modify functions).
    @benjamn in #8996

  • Ensure cache.identify never throws when primary key fields are missing, and include the source object in the error message when keyFields processing fails.
    @benjamn in #8679

  • The HttpLink constructor now accepts an optional print function that can be used to customize how GraphQL DocumentNode objects are transformed back into strings before they are sent over the network.
    @sarahgp in #8699

  • Make @apollo/client/testing a fully-fledged, independent entry point, instead of re-exporting @apollo/client/utilities/testing (which was never an entry point and no longer exists).
    @benjamn in #8769

  • A new nested entry point called @apollo/client/testing/core has been created. Importing from this entry point instead of @apollo/client/testing excludes any React-related dependencies.
    @wassim-k in #8687

  • Make cache.batch return the result of calling the options.update function.
    @benjamn in #8696

  • The NetworkError and ErrorResponse types have been changed to align more closely.
    @korywka in #8424

  • Include graphql@16 in peer deps.
    @brainkim in #8997

  • Update zen-observable-ts to eliminate transitive dependency on @types/zen-observable.
    @benjamn in #8695

React Refactoring

Improvements (due to @brainkim in #8875)

  • The useLazyQuery function now returns a promise with the result.

  • The useMutation result now exposes a method which can be reset.

Bug Fixes (due to @brainkim in #8596)

  • The useQuery and useLazyQuery hooks will now have ObservableQuery methods defined consistently.

  • Calling useLazyQuery methods like startPolling will start the query.

  • Calling the useLazyQuery execution function will now behave more like refetch. previousData will be preserved.

  • standby fetchPolicies will now act like skip: true more consistently.

  • Calling refetch on a skipped query will have no effect (issue #8270).

  • Prevent onError and onCompleted functions from firing continuously, and improving their polling behavior.