github apollographql/apollo-client @apollo/client@4.1.0-alpha.3

latest release: @apollo/client@4.0.8
pre-releaseone day ago

Minor Changes

  • #12971 d11eb40 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,
    }
  • #12971 d11eb40 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 }
    }
  • #12971 d11eb40 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,
    // }

Patch Changes

  • #12971 d11eb40 Thanks @jerelmiller! - Deduplicate watches created by useFragment, client.watchFragment, and cache.watchFragment that contain the same fragment, variables, and identifier. This should improve performance in situations where a useFragment or a client.watchFragment is used to watch the same object in multiple places of an application.

  • #12982 5c56b32 Thanks @jerelmiller! - Ignore top-level data values on subsequent chunks in incremental responses.

  • #12982 5c56b32 Thanks @jerelmiller! - Fix the Defer20220824Handler.SubsequentResult type to match the FormattedSubsequentIncrementalExecutionResult type in graphql@17.0.0-alpha.2.

  • #12973 072da24 Thanks @jerelmiller! - Update the accept header used with the GraphQL17Alpha9Handler to multipart/mixed;incrementalSpec=v0.2 to ensure the newest incremental delivery format is requested.

  • #12971 d11eb40 Thanks @jerelmiller! - DeepPartial<Array<TData>> now returns Array<DeepPartial<TData>> instead of Array<DeepPartial<TData | undefined>>.

Don't miss a new apollo-client release

NewReleases is sending notifications on new releases.