yarn @apollo/client 4.0.0-alpha.11
v4.0.0-alpha.11

latest releases: 4.0.0-alpha.22, 4.0.0-alpha.21, 4.0.0-alpha.20...
one month ago

Major Changes

  • #12576 a92ff78 Thanks @jerelmiller! - The cache and forceFetch properties are no longer available on context when calling operation.getContext(). cache can be accessed through the operation with operation.client.cache instead. forceFetch has been replaced with queryDeduplication which specifies whether queryDeduplication was enabled for the request or not.

  • #12576 a92ff78 Thanks @jerelmiller! - ApolloLink.execute now requires a third argument which provides the client that initiated the request to the link chain. If you use execute directly, add a third argument with a client property:

    ApolloLink.execute(link, operation, { client });
    
    // or if you import the `execute` function directly:
    execute(link, operation, { client });
  • #12566 ce4b488 Thanks @jerelmiller! - Don't broadcastQueries when a query is torn down.

Minor Changes

  • #12576 a92ff78 Thanks @jerelmiller! - Provide an extension to define types for context passed to the link chain. To define your own types, use declaration merging to add properties to the DefaultContext type.

    // @apollo-client.d.ts
    // This import is necessary to ensure all Apollo Client imports
    // are still available to the rest of the application.
    import "@apollo/client";
    
    declare module "@apollo/client" {
      interface DefaultContext extends Record<string, any> {
        myProperty: string;
      }
    }

    Links that provide context options can be used with this type to add those context types to DefaultContext. For example, to add context options from HttpLink, add the following code:

    import { HttpLink } from "@apollo/client";
    
    declare module "@apollo/client" {
      interface DefaultContext extends HttpLink.ContextOptions {
        myProperty: string;
      }
    }

    At this time, the following built-in links support context options:

    • HttpLink.ContextOptions
    • BatchHttpLink.ContextOptions
  • #12576 a92ff78 Thanks @jerelmiller! - Add a client property to the operation passed to the link chain. This client is set as the client making the request to the link chain.

Patch Changes

  • #12574 0098ec9 Thanks @jerelmiller! - Export gql from the @apollo/client/react entrypoint.

  • #12572 3dc50e6 Thanks @jerelmiller! - Adjust useMutation types to better handle required variables. When required variables are missing, TypeScript will now complain if they are not provided either to the hook or the returned mutate function. Providing required variables to useMutation will make them optional in the returned mutate function.

Don't miss a new client release

NewReleases is sending notifications on new releases.