Skip to content

Releases: apollographql/apollo-client

@apollo/client@4.1.2

21 Jan 09:31
6bce77d

Choose a tag to compare

Patch Changes

  • #13105 8b62263 Thanks @phryneas! - ssrMode, ssrForceFetchDelay or prioritizeCacheValues should not override fetchPolicy: 'cache-only', fetchPolicy: 'no-cache', fetchPolicy: 'standby', skip: true, or skipToken when reading the initial value of an ObservableQuery.

  • #13105 8b62263 Thanks @phryneas! - Fix skipToken in useQuery with prerenderStatic and related SSR functions.

  • #13105 8b62263 Thanks @phryneas! - Avoid fetches with fetchPolicy: no-cache in useQuery with prerenderStatic and related SSR functions.

@apollo/client@4.1.1

20 Jan 17:46
c605345

Choose a tag to compare

Patch Changes

  • #13103 dee7dcf Thanks @jerelmiller! - Ensure @client fields that are children of aliased server fields are resolved correctly.

@apollo/client@4.1.0

15 Jan 23:19
1140026

Choose a tag to compare

Minor Changes

  • #13043 65e66ca Thanks @jerelmiller! - Support headers transport for enhanced client awareness.

  • #12927 785e223 Thanks @jerelmiller! - You can now provide a callback function as the context option on the mutate function returned by useMutation. The callback function is called with the value of the context option provided to the useMutation hook. This is useful if you'd like to merge the context object provided to the useMutation hook with a value provided to the mutate function.

    function MyComponent() {
      const [mutate, result] = useMutation(MUTATION, {
        context: { foo: true },
      });
    
      async function runMutation() {
        await mutate({
          // sends context as { foo: true, bar: true }
          context: (hookContext) => ({ ...hookContext, bar: true }),
        });
      }
    
      // ...
    }
  • #12923 94ea3e3 Thanks @jerelmiller! - Fix an issue where deferred payloads that returned arrays with fewer items than the original cached array would retain items from the cached array. This change includes @stream arrays where stream arrays replace the cached arrays.

  • #12927 96b531f Thanks @jerelmiller! - Don't set the fallback value of a @client field to null when a read function is defined. Instead the read function will be called with an existing value of undefined to allow default arguments to be used to set the returned value.

    When a read function is not defined nor is there a defined resolver for the field, warn and set the value to null only in that instance.

  • #12927 45ebb52 Thanks @jerelmiller! - Add support for from: null in client.watchFragment and cache.watchFragment. When from is null, the emitted result is:

    {
      data: null,
      dataState: "complete",
      complete: true,
    }
  • #12926 2b7f2c1 Thanks @jerelmiller! - Support the newer incremental delivery format for the @defer directive implemented in graphql@17.0.0-alpha.9. Import the GraphQL17Alpha9Handler to use the newer incremental delivery format with @defer.

    import { GraphQL17Alpha9Handler } from "@apollo/client/incremental";
    
    const client = new ApolloClient({
      // ...
      incrementalHandler: new GraphQL17Alpha9Handler(),
    });

    [!NOTE]
    In order to use the GraphQL17Alpha9Handler, the GraphQL server MUST implement the newer incremental delivery format. You may see errors or unusual behavior if you use the wrong handler. If you are using Apollo Router, continue to use the Defer20220824Handler because Apollo Router does not yet support the newer incremental delivery format.

  • #12927 45ebb52 Thanks @jerelmiller! - Add support for arrays with useFragment, useSuspenseFragment, and client.watchFragment. This allows the ability to use a fragment to watch multiple entities in the cache. Passing an array to from will return data as an array where each array index corresponds to the index in the from array.

    function MyComponent() {
      const result = useFragment({
        fragment,
        from: [item1, item2, item3],
      });
    
      // `data` is an array with 3 items
      console.log(result); // { data: [{...}, {...}, {...}], dataState: "complete", complete: true }
    }
  • #12927 45ebb52 Thanks @jerelmiller! - Add a getCurrentResult function to the observable returned by client.watchFragment and cache.watchFragment that returns the current value for the watched fragment.

    const observable = client.watchFragment({
      fragment,
      from: { __typename: "Item", id: 1 },
    });
    
    console.log(observable.getCurrentResult());
    // {
    //   data: {...},
    //   dataState: "complete",
    //   complete: true,
    // }
  • #13038 109efe7 Thanks @jerelmiller! - Add the from option to readFragment, watchFragment, and updateFragment.

  • #12918 2e224b9 Thanks @jerelmiller! - Add support for the @stream directive on both the Defer20220824Handler and the GraphQL17Alpha2Handler.

    [!NOTE]
    The implementations of @stream differ in the delivery of incremental results between the different GraphQL spec versions. If you upgrading from the older format to the newer format, expect the timing of some incremental results to change.

  • #13056 b224efc Thanks @jerelmiller! - InMemoryCache no longer filters out explicitly returned undefined items from read functions for array fields. This now makes it possible to create read functions on array fields that return partial data and trigger a fetch for the full list.

  • #13058 121a2cb Thanks @jerelmiller! - Add an extensions option to cache.write, cache.writeQuery, and client.writeQuery. This makes extensions available in cache merge functions which can be accessed with the other merge function options.

    As a result of this change, any extensions returned in GraphQL operations are now available in merge in the cache writes for these operations.

  • #12927 96b531f Thanks @jerelmiller! - Add an abstract resolvesClientField function to ApolloCache that can be used by caches to tell LocalState if it can resolve a @client field when a local resolver is not defined.

    LocalState will emit a warning and set a fallback value of null when no local resolver is defined and resolvesClientField returns false, or isn't defined. Returning true from resolvesClientField signals that a mechanism in the cache will set the field value. In this case, LocalState won't set the field value.

  • #13078 bf1e0dc Thanks @phryneas! - Use the default stream merge function for @stream fields only if stream info is present. This change means that using the older Defer20220824Handler will not use the default stream merge function and will instead truncate the streamed array on the first chunk.

Patch Changes

  • #12884 d329790 Thanks @phryneas! - Ensure that PreloadedQueryRef instances are unsubscribed when garbage collected

  • #13086 1a1d408 Thanks @phryneas! - Change the returned value from null to {} when all fields in a query were skipped.

    This also fixes a bug where useSuspenseQuery would suspend indefinitely when all fields were skipped.

  • #13010 7627000 Thanks @jerelmiller! - Fix an issue where errors parsed from incremental chunks in ErrorLink might throw when using the GraphQL17Alpha9Handler.

  • #12927 45ebb52 Thanks [@jerelmiller](https...

Read more

@apollo/client@4.0.13

13 Jan 20:47
b49983b

Choose a tag to compare

Patch Changes

  • #13094 9cbe2c2 Thanks @phryneas! - Ensure that compact and mergeOptions preserve symbol keys.

    This fixes an issue where the change introduced in 4.0.11 via #13049 would not
    be applied if defaultOptions for watchQuery were declared.

    Please note that compact and mergeOptions are considered internal utilities
    and they might have similar behavior changes in future releases.
    Do not use them in your application code - a change like this is not considered
    breaking and will not be announced as such.

@apollo/client@4.0.12

12 Jan 09:17
c13d34f

Choose a tag to compare

Patch Changes

  • #13077 f322460 Thanks @phryneas! - Fix a potential memory leak where Trie nodes would remain in memory too long.

@apollo/client@4.1.0-rc.1

09 Jan 18:55
9041611

Choose a tag to compare

Pre-release

Patch Changes

  • #13086 1a1d408 Thanks @phryneas! - Change the returned value from null to {} when all fields in a query were skipped.

    This also fixes a bug where useSuspenseQuery would suspend indefinitely when all fields were skipped.

  • #13071 99ffe9a Thanks @phryneas! - prerenderStatic: Expose return value of renderFunction to userland, fix aborted property.

    This enables usage of resumeAndPrerender with React 19.2.

@apollo/client@4.1.0-rc.0

07 Jan 17:46
f94047a

Choose a tag to compare

Pre-release

Minor Changes

  • #13078 bf1e0dc Thanks @phryneas! - Use the default stream merge function for @stream fields only if stream info is present. This change means that using the older Defer20220824Handler will not use the default stream merge function and will instead truncate the streamed array on the first chunk.

Patch Changes

  • #13083 f3c2be1 Thanks @phryneas! - Expose the ExtensionsWithStreamInfo type for extensions in Cache.writeQuery, Cache.write and Cache.update so other cache implementations also can correctly access them.

  • #13082 c257418 Thanks @phryneas! - Pass streamInfo through result extensions as a WeakRef.

  • #13081 1e06ad7 Thanks @jerelmiller! - Avoid calling merge functions more than once for the same incremental chunk.

@apollo/client@4.0.12-beta.0

23 Dec 13:10
0e60e63

Choose a tag to compare

Pre-release

Patch Changes

@apollo/client@4.1.0-alpha.9

18 Dec 19:13
9b426d6

Choose a tag to compare

Pre-release

Minor Changes

  • #13056 b224efc Thanks @jerelmiller! - InMemoryCache no longer filters out explicitly returned undefined items from read functions for array fields. This now makes it possible to create read functions on array fields that return partial data and trigger a fetch for the full list.

  • #13058 121a2cb Thanks @jerelmiller! - Add an extensions option to cache.write, cache.writeQuery, and client.writeQuery. This makes extensions available in cache merge functions which can be accessed with the other merge function options.

    As a result of this change, any extensions returned in GraphQL operations are now available in merge in the cache writes for these operations.

Patch Changes

  • #13053 23ca0ba Thanks @phryneas! - Use memoized observable mapping when using watchFragment, useFragment or useSuspenseFragment.

@apollo/client@4.0.11

16 Dec 17:00
0775976

Choose a tag to compare

Patch Changes

  • #13050 8020829 Thanks @phryneas! - Replace usage of findLast with more backwards-compatible methods.

  • #13049 05638de Thanks @phryneas! - Fixes an issue where queries starting with skipToken or lazy queries from useLazyQuery were included in client.refetchQueries() before they had been executed for the first time. While generally queries with a standby fetchPolicy should be included in refetch, these queries never had variables passed in, so they should be excluded until they have run once and received their actual variables.

    These queries are now properly excluded from refetch operations until after their initial execution.

    This change adds a new hidden option to client.watchQuery, [variablesUnknownSymbol], which may be set true for queries starting with a fetchPolicy of standby. It will only be applied when creating the ObservableQuery instance and cannot be changed later. This flag indicates that the query's variables are not yet known, and thus it should be excluded from refetch operations until they are.
    This option is not meant for everyday use and is intended for framework integrations only.