github apollographql/apollo-client v3.8.0-rc.2

latest releases: v3.11.10, v3.11.9, v3.12.0-alpha.0...
pre-release15 months ago

3.8.0-rc.2

Minor Changes

  • #11112 b4aefcfe9 Thanks @jerelmiller! - Adds support for a skipToken sentinel that can be used as options in useSuspenseQuery and useBackgroundQuery to skip execution of a query. This works identically to the skip option but is more type-safe and as such, becomes the recommended way to skip query execution. As such, the skip option has been deprecated in favor of skipToken.

    We are considering the removal of the skip option from useSuspenseQuery and useBackgroundQuery in the next major. We are releasing with it now to make migration from useQuery easier and make skipToken more discoverable.

    import { skipToken } from "@apollo/client";
    
    const id: number | undefined;
    
    const { data } = useSuspenseQuery(
      query,
      id ? { variables: { id } } : skipToken
    );

    Breaking change

    Previously useBackgroundQuery would always return a queryRef whenever query execution was skipped. This behavior been updated to return a queryRef only when query execution is enabled. If initializing the hook with it skipped, queryRef is now returned as undefined.

    To migrate, conditionally render the component that accepts the queryRef as props.

    Before

    function Parent() {
      const [queryRef] = useBackgroundQuery(query, skip ? skipToken : undefined);
      //      ^? QueryReference<TData | undefined>
    
      return <Child queryRef={queryRef} />;
    }
    
    function Child({
      queryRef,
    }: {
      queryRef: QueryReference<TData | undefined>;
    }) {
      const { data } = useReadQuery(queryRef);
    }

    After

    function Parent() {
      const [queryRef] = useBackgroundQuery(query, skip ? skipToken : undefined);
      //      ^? QueryReference<TData> | undefined
    
      return queryRef ? <Child queryRef={queryRef} /> : null;
    }
    
    function Child({ queryRef }: { queryRef: QueryReference<TData> }) {
      const { data } = useReadQuery(queryRef);
    }

Patch Changes

  • #11086 0264fee06 Thanks @jerelmiller! - Fix an issue where a call to refetch, fetchMore, or changing skip to false that returned a result deeply equal to data in the cache would get stuck in a pending state and never resolve.

  • #11115 78739e3ef Thanks @phryneas! - Enforce export type for all type-level exports.

  • #11103 e3d611daf Thanks @caylahamann! - Fixes a bug in useMutation so that onError is called when an error is returned from the request with errorPolicy set to 'all' .

  • #11083 f766e8305 Thanks @phryneas! - Adjust the rerender timing of useQuery to more closely align with useFragment. This means that cache updates delivered to both hooks should trigger renders at relatively the same time. Previously, the useFragment might rerender much faster leading to some confusion.

  • #11082 0f1cde3a2 Thanks @phryneas! - Restore Apollo Client 3.7 getApolloContext behaviour

Don't miss a new apollo-client release

NewReleases is sending notifications on new releases.