Packages

@apollo/client

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

Your version

3.11.0

22 Jul 2024Where it was published

3.14.1 is the newest release of 3.x.

In short

2 breaking1 removed2 deprecated14 new3 fixed

  • breaking

    Changes usages of the GraphQLError type to GraphQLFormattedError.

  • breaking

    Call nextFetchPolicy with "variables-changed" even if there is a fetchPolicy specified.

  • removed

    Remove deprecated watchFragment option, canonizeResults

  • deprecated

    Deprecates experimental schema testing utilities introduced in 3.10 in favor of recommending @apollo/graphql-testing-library.

  • deprecated

    Document (and deprecate) the previously undocumented errors property on the useQuery QueryResult type.

Release note

Potentially Breaking Fixes

  • breaking

    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.

  • breaking

    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

  • Add support for subscribeToMore function to useQueryRefHandlers.

  • Support extensions in useSubscription

  • Add support for subscribeToMore function to useLoadableQuery.

  • Reimplement useSubscription to fix rules of React violations.

  • Rewrite big parts of useQuery and useLazyQuery to be more compliant with the Rules of React and React Compiler

  • 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.

  • Add support for subscribeToMore function to useBackgroundQuery.

  • deprecated

    Deprecates experimental schema testing utilities introduced in 3.10 in favor of recommending @apollo/graphql-testing-library.

Patch Changes

  • Add React 19 RC to peerDependencies

  • Add restart function to useSubscription.

  • removed

    Remove deprecated watchFragment option, canonizeResults

  • createSchemaFetch: simulate serialized errors instead of an ApolloError instance

  • Add cause field to ApolloError.

  • MockLink: Add query default variables if not specified in mock request

  • watchFragment: forward additional options to diffOptions

  • Fix issue where mutations were not accessible by Apollo Client Devtools in 3.11.0-rc.0.

  • Allow IgnoreModifier to be returned from a optimisticResponse function when inferring from a TypedDocumentNode when used with a generic argument.

  • deprecated

    Document (and deprecate) the previously undocumented errors property on the useQuery QueryResult type.

  • Allow wrapping createQueryPreloader

  • Add ignoreResults option to useSubscription