Skip to content

Releases: apollographql/apollo-client

v3.14.0-alpha.1

01 Jul 08:05
45e6ee6

Choose a tag to compare

v3.14.0-alpha.1 Pre-release
Pre-release

Minor Changes

  • #12752 8b779b4 Thanks @jerelmiller! - Add deprecations and warnings to remaining APIs changed in Apollo Client 4.0.

  • #12751 567cad8 Thanks @jerelmiller! - Add @deprecated tags to all properties returned from any query API (e.g. client.query, observableQuery.refetch, etc.), client.mutate, and client.subscribe that are no longer available in Apollo Client 4.0.

  • #12751 567cad8 Thanks @jerelmiller! - Warn when using a standby fetch policy with client.query.

@apollo/[email protected]

01 Jul 08:08
5ff16fb

Choose a tag to compare

Pre-release

Major Changes

  • #12731 0198870 Thanks @phryneas! - Ship React Compiler compiled React hooks in @apollo/client/react/compiled.

    We now ship a React-Compiler compiled version of the React hooks in
    @apollo/client/react/compiled.

    This entry point contains everything that @apollo/client/react does,
    so you can use it as a drop-in replacement in your whole application
    if you choose to use the compiled hooks.

Minor Changes

  • #12753 b85818d Thanks @jerelmiller! - Renamed client.reFetchObservableQueries to client.refetchObservableQueries.
    client.reFetchObservableQueries is still available as an alias, but is now
    deprecated and will be removed in a future major version.

v3.14.0-alpha.0

27 Jun 18:24
3e7cfe8

Choose a tag to compare

v3.14.0-alpha.0 Pre-release
Pre-release

Minor Changes

  • #12746 0bcd2f4 Thanks @jerelmiller! - Add warnings and deprecations for options and methods for all React APIs.

  • #12746 0bcd2f4 Thanks @jerelmiller! - Add preloadQuery.toPromise(queryRef) as a replacement for queryRef.toPromise(). queryRef.toPromise() has been removed in Apollo Client 4.0 in favor of preloadQuery.toPromise and is now considered deprecated.

  • #12736 ea89440 Thanks @jerelmiller! - Add deprecations and deprecation warnings for ApolloClient options and methods.

  • #12459 1c5a031 Thanks @jerelmiller! - Reset addTypenameTransform and fragments caches when calling cache.gc() only when resetResultCache is true.

  • #12743 92ad409 Thanks @jerelmiller! - Add deprecations and warnings for addTypename in InMemoryCache and MockedProvider.

  • #12743 92ad409 Thanks @jerelmiller! - Add deprecations and warnings for canonizeResults.

Patch Changes

  • #12750 ecf3de1 Thanks @phryneas! - Prevent field policies from overwriting/merging into supertype field policies.

@apollo/[email protected]

27 Jun 18:19
0e686a1

Choose a tag to compare

Pre-release

Major Changes

  • #12742 575bf3e Thanks @jerelmiller! - The new SetContextLink flips the prevContext and operation arguments in the callback. The setContext function has remained unchanged.

    - new SetContextLink((operation, prevContext) => {
    + new SetContextLink((prevContext, operation) => {
      // ...
    })
  • #12742 575bf3e Thanks @jerelmiller! - The operation argument to the callback passed to SetContextLink is now of type SetContextLink.SetContextOperation which is an Operation without the getContext or setContext functions. Previously the type of operation was GraphQLRequest which had access to a context property. The context property was always undefined and could result in bugs when using it instead of the prevContext argument.

    This change means the operation argument now contains an accessible client property.

Minor Changes

  • #12740 1c6e03c Thanks @phryneas! - Overridable types for dataState: "complete", dataState: "streaming" and
    dataState: "partial" responses.

    This adds the DataValue namespace exported from Apollo Client with the three
    types DataValue.Complete, DataValue.Streaming and DataValue.Partial.

    These types will be used to mark TData in the respective states.

    • Complete defaults to TData
    • Streaming defaults to TData
    • Partial defaults to DeepPartial<TData>

    All three can be overwritten, e.g. to be DeepReadonly using higher kinded types
    by following this pattern:

    import { HKT, DeepPartial } from "@apollo/client/utilities";
    import { DeepReadonly } from "some-type-helper-library";
    
    interface CompleteOverride extends HKT {
      return: DeepReadonly<this["arg1"]>;
    }
    
    interface StreamingOverride extends HKT {
      return: DeepReadonly<this["arg1"]>;
    }
    
    interface PartialOverride extends HKT {
      return: DeepReadonly<DeepPartial<this["arg1"]>>;
    }
    
    declare module "@apollo/client" {
      export interface TypeOverrides {
        Complete: CompleteOverride;
        Streaming: StreamingOverride;
        Partial: PartialOverride;
      }
    }

Patch Changes

@apollo/[email protected]

27 Jun 18:19
0e686a1

Choose a tag to compare

Pre-release

Major Changes

  • #12727 b845906 Thanks @jerelmiller! - Add a codemod that renames old import locations from 3.x entrypoint to their 4.x entrypoint.

    Run the codemod using the following command:

    npx @apollo/client-codemod-migrate-3-to-4 --parser tsx ./src/**/*.{ts,tsx}

    The codemod supports .js, .jsx, .ts, and .tsx files.

@apollo/[email protected]

24 Jun 16:00
3bdf391

Choose a tag to compare

Pre-release

Major Changes

Minor Changes

  • #12725 89ac725 Thanks @jerelmiller! - Add operationType to operation in ApolloLink. This means that determining whether a query is a specific operation type can now be compared with this property instead of using getMainDefinition.

    - import { getMainDefinition } from "@apollo/client/utilities";
    + import { OperationTypeNode } from "graphql";
    
    ApolloLink.split(
    - ({ query }) => {
    -   const definition = getMainDefinition(query);
    -   return (
    -     definition.kind === 'OperationDefinition' &&
    -     definition.operation === 'subscription'
    -   );
    -   return
    - },
    + ({ operationType }) => {
    +   return operationType === OperationTypeNode.SUBSCRIPTION;
    + },
      conditionTrueLink,
      conditionFalseLink,
    );

Patch Changes

  • #12728 07a0c8c Thanks @jerelmiller! - Export the IgnoreModifier type from @apollo/client/cache.

  • #12735 5159880 Thanks @jerelmiller! - Change the unsafePreviousData argument on UpdateQueryMapFn and SubscribeToMoreQueryFn to a DeepPartial since the result may contain partial data.

  • #12734 037979d Thanks @jerelmiller! - Don't warn about a missing resolver if a @client does not have a configured resolver. It is possible the cache contains a read function for the field and the warning added confusion.

    Note that read functions without a defined resolver will receive the existing argument as null instead of undefined even when data hasn't been written to the cache. This is because LocalState sets a default value of null when a resolver is not defined to ensure that the field contains a value in case a read function is not defined rather than omitting the field entirely.

  • #12725 89ac725 Thanks @jerelmiller! - Export getMainDefinition from @apollo/client/utilities.

  • #12729 699c830 Thanks @jerelmiller! - Ensure useQuery rerenders when notifyOnNetworkStatusChange is false and a refetch that changes variables returns a result deeply equal to previous variables.

@apollo/[email protected]

19 Jun 15:42
449c3ea

Choose a tag to compare

Pre-release

Major Changes

@apollo/[email protected]

18 Jun 21:53
f1eba94

Choose a tag to compare

Pre-release

Major Changes

@apollo/[email protected]

18 Jun 21:22
44645d2

Choose a tag to compare

Pre-release

Major Changes

  • #12712 bbb2b61 Thanks @jerelmiller! - An error is now thrown when trying to call fetchMore on a cache-only query.

  • #12712 bbb2b61 Thanks @jerelmiller! - cache-only queries are no longer refetched when calling client.reFetchObservableQueries when includeStandby is true.

  • #12705 a60f411 Thanks @jerelmiller! - cache-only queries will now initialize with loading: false and networkStatus: NetworkStatus.ready when there is no data in the cache.

    This means useQuery will no longer render a short initial loading state before rendering loading: false and ObservableQuery.getCurrentResult() will now return loading: false immediately.

  • #12712 bbb2b61 Thanks @jerelmiller! - cache-only queries are now excluded from client.refetchQueries in all situations. cache-only queries affected by updateCache are also excluded from refetchQueries when onQueryUpdated is not provided.

  • #12681 b181f98 Thanks @jerelmiller! - Changing most options when rerendering useQuery will no longer trigger a reobserve which may cause network fetches. Instead, the changed options will be applied to the next cache update or fetch.

    Options that now trigger a reobserve when changed between renders are:

    • query
    • variables
    • skip
    • Changing fetchPolicy to or from standby
  • #12714 0e39469 Thanks @phryneas! - Rework option handling for fetchMore.

    • Previously, if the query option was specified, no options would be inherited
      from the underlying ObservableQuery.
      Now, even if query is specified, all unspecified options except for variables will be inherited from the underlying ObservableQuery.
    • If query is not specified, variables will still be shallowly merged with the variables of the underlying ObservableQuery. If a query option is specified, the variables passed to fetchMore are used instead.
    • errorPolicy of fetchMore will now always default to "none" instead of inherited from the ObservableQuery options. This can prevent accidental cache writes of partial data for a paginated query. To opt into receive partial data that may be written to the cache, pass an errorPolicy to fetchMore to override the default.
  • #12700 8e96e08 Thanks @phryneas! - Added a new Streaming type that will mark data in results while dataStatus
    is "streaming".

    Streaming<TData> defaults to TData, but can be overwritten in userland to
    integrate with different codegen dialects.

    You can override this type globally - this example shows how to override it
    with DeepPartial<TData>:

    import { HKT, DeepPartial } from "@apollo/client/utilities";
    
    type StreamingOverride<TData> = DeepPartial<TData>;
    
    interface StreamingOverrideHKT extends HKT {
      return: StreamingOverride<this["arg1"]>;
    }
    
    declare module "@apollo/client" {
      export interface TypeOverrides {
        Streaming: StreamingOverrideHKT;
      }
    }
  • #12499 ce35ea2 Thanks @phryneas! - Enable React compiler for hooks in ESM builds.

  • #12704 45dba43 Thanks @jerelmiller! - The ErrorResponse object passed to the disable and retry callback options provided to createPersistedQueryLink no longer provides separate graphQLErrors and networkError properties and instead have been combined to a single error property of type ErrorLike.

    // The following also applies to the `retry` function since it has the same signature
    createPersistedQueryLink({
    - disable: ({ graphQLErrors, networkError }) => {
    + disable: ({ error }) => {
    -   if (graphQLErrors) {
    +   if (CombinedGraphQLErrors.is(error)) {
          // ... handle GraphQL errors
        }
    
    -   if (networkError) {
    +   if (error) {
          // ... handle link errors
        }
    
        // optionally check for a specific kind of error
    -   if (networkError) {
    +   if (ServerError.is(error)) {
          // ... handle a server error
        }
    });

    The response property has also been renamed to result.

    createPersistedQueryLink({
    -  disable: ({ response }) => {
    +  disable: ({ result }) => {
          // ... handle GraphQL errors
        }
      }
    });
  • #12712 bbb2b61 Thanks @jerelmiller! - cache-only queries no longer poll when a pollInterval is set. Instead a warning is now emitted that polling has no effect. If the fetchPolicy is changed to cache-only after polling is already active, polling is stopped.

  • #12704 45dba43 Thanks @jerelmiller! - The response property in onError link has been renamed to result.

    - onError(({ response }) => {
    + onError(({ result }) => {
        // ...
    });
  • #12715 0be0b3f Thanks @phryneas! - All links are now available as classes. The old creator functions have been deprecated.

    Please migrate these function calls to class creations:

    import {
    - setContext
    + SetContextLink
    } from "@apollo/client/link/context"
    
    -const link = setContext(...)
    +const link = new SetContextLink(...)
    import {
    - createHttpLink
    + HttpLink
    } from "@apollo/client/link/http"
    
    -const link = createHttpLink(...)
    +const link = new HttpLink(...)
    import {
    - createPersistedQueryLink
    + PersistedQueryLink
    } from "@apollo/client/link/persisted-queries"
    
    -const link = createPersistedQueryLink(...)
    +const link = new PersistedQueryLink(...)
    import {
    - removeTypenameFromVariables
    + RemoveTypenameFromVariablesLink
    } from "@apollo/client/link/remove-typename"
    
    -const link = removeTypenameFromVariables(...)
    +const link = new RemoveTypenameFromVariablesLink(...)

Minor Changes

  • #12711 f730f83 Thanks @jerelmiller! - Add an extensions property to CombinedGraphQLErrors to capture any extensions from the original response.

  • #12700 8e96e08 Thanks @phryneas! - The callback function that can be passed to the ApolloClient.mutate
    refetchQueries option will now receive a FormattedExecutionResult with an
    additional dataState option that describes if the result is "streaming"
    or "complete".
    This indicates whether the data value is of type

    • Unmasked<TData> (if "complete")
    • Streaming<Unmasked<TData>> (if "streaming")
  • #12714 0e39469 Thanks @phryneas! - Allow passing errorPolicy option to fetchMore and change default value to "none".

  • #12714 0e39469 Thanks @phryneas! - The FetchMoreQueryOptions type has been inlined into FetchMoreOptions, and
    FetchMoreQueryOptions has been removed.

  • #12700 [`8e96...

Read more

@apollo/[email protected]

13 Jun 17:47
ddf196a

Choose a tag to compare

Pre-release

Major Changes

  • #12673 cee90ab Thanks @phryneas! - The includeExtensions option of HttpLink and BatchHttpLink now defaults
    to true.

    If includeExtensions is true, but extensions is not set or empty, extensions
    will not be included in outgoing requests.

  • #12673 cee90ab Thanks @phryneas! - The ApolloClient constructor options name and version that are used to
    configure the client awareness feature have moved onto a clientAwareness key.

    const client = new ApolloClient({
      // ..
    -  name: "my-app",
    -  version: "1.0.0",
    +  clientAwareness: {
    +    name: "my-app",
    +    version: "1.0.0",
    +  },
    });
  • #12690 5812759 Thanks @phryneas! - Aliasing any other field to __typename is now forbidden.

  • #12690 5812759 Thanks @phryneas! - Aliasing a field to an alias beginning with __ac_ is now forbidden - this namespace is now reserved for internal use.

  • #12673 cee90ab Thanks @phryneas! - Adds enhanced client awareness to the client.

    HttpLink and BatchHttpLink will now per default send information about the
    client library you are using in extensions.

    This could look like this:

    {
      "query": "query GetUser($id: ID!) { user(id: $id) { __typename id name } }",
      "variables": {
        "id": 5
      },
      "extensions": {
        "clientLibrary": {
          "name": "@apollo/client",
          "version": "4.0.0"
        }
      }
    }

    This feature can be disabled by passing enhancedClientAwareness: { transport: false } to your
    ApolloClient, HttpLink or BatchHttpLink constructor options.

Minor Changes

  • #12698 be77d1a Thanks @phryneas! - Adjusted the accept header for multipart requests according to the new GraphQL over HTTP spec with these changes:

    -multipart/mixed;boundary=graphql;subscriptionSpec=1.0,application/json
    +multipart/mixed;boundary=graphql;subscriptionSpec=1.0,application/graphql-response+json,application/json;q=0.9
    -multipart/mixed;deferSpec=20220824,application/json
    +multipart/mixed;deferSpec=20220824,application/graphql-response+json,application/json;q=0.9
  • #12673 cee90ab Thanks @phryneas! - Add the new ClientAwarenessLink.

    This link is already included in HttpLink and BatchHttpLink to enable the
    "client awareness" and "enhanced client awareness" features, but you can also use
    ClientAwarenessLink directly in your link chain to combine it with other
    terminating links.

    If you want to save the bundle size that ClientAwarenessLink adds to HttpLink
    and BatchHttpLink, you can use BaseHttpLink or BaseBatchHttpLink instead.
    These links come without the ClientAwarenessLink included.

    For example:

    import {
      ApolloClient,
    -  HttpLink,
    } from "@apollo/client";
    +import { BaseHttpLink } from "@apollo/client/link/http";
    
    const client = new ApolloClient({
    -  link: new HttpLink({
    +  link: new BaseHttpLink({
        uri,
      }),
      cache: new InMemoryCache(),
    });
  • #12698 be77d1a Thanks @phryneas! - Adds an accept option to HttpOptions that allows to add additional Accept headers to be merged in without overriding user-specified or default accept headers.

Patch Changes

  • #12673 cee90ab Thanks @phryneas! - Fixed a bug in PersistedQueryLink where the persistedQuery extension would still be sent after a PersistedQueryNotSupported if includeExtensions was enabled on HttpLink.