Skip to content

Releases: apollographql/apollo-client

v3.8.0-rc.2

03 Aug 09:55
c6c489b
Compare
Choose a tag to compare
v3.8.0-rc.2 Pre-release
Pre-release

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

v3.8.0-rc.1

03 Aug 09:55
8f90e9f
Compare
Choose a tag to compare
v3.8.0-rc.1 Pre-release
Pre-release

3.8.0-rc.1

Patch Changes

  • #11071 4473e925a Thanks @jerelmiller! - #10509 introduced some helpers for determining the type of operation for a GraphQL query. This imported the OperationTypeNode from graphql-js which is not available in GraphQL 14. To maintain compatibility with graphql-js v14, this has been reverted to use plain strings.

v3.8.0-rc.0

03 Aug 09:55
213bde2
Compare
Choose a tag to compare
v3.8.0-rc.0 Pre-release
Pre-release

3.8.0-rc.0

Minor Changes

  • #11058 89bf33c42 Thanks @phryneas! - (Batch)HttpLink: Propagate AbortErrors to the user when a user-provided signal is passed to the link. Previously, these links would swallow all AbortErrors, potentially causing queries and mutations to never resolve. As a result of this change, users are now expected to handle AbortErrors when passing in a user-provided signal.

  • #11040 125ef5b2a Thanks @phryneas! - HttpLink/BatchHttpLink: Abort the AbortController signal more granularly.
    Before this change, when HttpLink/BatchHttpLink created an AbortController
    internally, the signal would always be .aborted after the request was completed. This could cause issues with Sentry Session Replay and Next.js App Router Cache invalidations, which just replayed the fetch with the same options - including the cancelled AbortSignal.

    With this change, the AbortController will only be .abort()ed by outside events,
    not as a consequence of the request completing.

Patch Changes

  • #11053 c0ca70720 Thanks @phryneas! - Add SuspenseCache as a lazy hidden property on ApolloClient.
    This means that SuspenseCache is now an implementation details of Apollo Client
    and you no longer need to manually instantiate it and no longer need to pass it
    into ApolloProvider.
    Trying to instantiate a SuspenseCache instance in your code will now throw an
    error.

    Migration:

    -import { SuspenseCache } from '@apollo/client';
    
    -const suspenseCache = new SuspenseCache();
    
    -<ApolloProvider client={client} suspenseCache={suspenseCache} />;
    +<ApolloProvider client={client} />;

v3.8.0-beta.7

03 Aug 09:55
709cf62
Compare
Choose a tag to compare
v3.8.0-beta.7 Pre-release
Pre-release

3.8.0-beta.7

Minor Changes

  • #10994 2ebbd3abb Thanks @phryneas! - Add .js file extensions to imports in src and dist/*/.d.ts

  • #11045 9c1d4a104 Thanks @jerelmiller! - When changing variables back to a previously used set of variables, do not automatically cache the result as part of the query reference. Instead, dispose of the query reference so that the InMemoryCache can determine the cached behavior. This means that fetch policies that would guarantee a network request are now honored when switching back to previously used variables.

  • #10915 3a62d8228 Thanks @phryneas! - Changes how development-only code is bundled in the library to more reliably enable consuming bundlers to reduce production bundle sizes while keeping compatibility with non-node environments.

Patch Changes

  • #11026 b8d405eee Thanks @phryneas! - Store React.Context instance mapped by React.createContext instance, not React.version.
    Using React.version can cause problems with preact, as multiple versions of preact will all identify themselves as React 17.0.2.

  • #11000 1d43ab616 Thanks @phryneas! - Use import * as React everywhere. This prevents an error when importing @apollo/client in a React Server component. (see #10974)

  • #11035 a3ab7456d Thanks @jerelmiller! - Incrementally re-render deferred queries after calling refetch or setting skip to false to match the behavior of the initial fetch. Previously, the hook would not re-render until the entire result had finished loading in these cases.

v3.8.0-beta.6

03 Aug 09:55
788262d
Compare
Choose a tag to compare
v3.8.0-beta.6 Pre-release
Pre-release

3.8.0-beta.6

Patch Changes

  • #11027 e47cfd04e Thanks @phryneas! - Prevents the DevTool installation warning to be turned into a documentation link.

  • #11013 5ed2cfdaf Thanks @alessbell! - Make private fields inFlightLinkObservables and fetchCancelFns protected in QueryManager in order to make types available in @apollo/experimental-nextjs-app-support package when extending the ApolloClient class.

  • #11032 6a4da900a Thanks @jerelmiller! - Throw errors in useSuspenseQuery for errors returned in incremental chunks when errorPolicy is none. This provides a more consistent behavior of the errorPolicy in the hook.

    Potentially breaking change

    Previously, if you issued a query with @defer and relied on errorPolicy: 'none' to set the error property returned from useSuspenseQuery when the error was returned in an incremental chunk, this error is now thrown. Switch the errorPolicy to all to avoid throwing the error and instead return it in the error property.

  • #11025 6092b6edf Thanks @jerelmiller! - useSuspenseQuery and useBackgroundQuery will now properly apply changes to its options between renders.

v3.7.17

05 Jul 19:13
69563f1
Compare
Choose a tag to compare

Patch Changes

  • #10631 b93388d75 Thanks @phryneas! - ObservableQuery.getCurrentResult: skip the cache if the running query should not access the cache

v3.8.0-beta.5

03 Aug 09:55
3a05815
Compare
Choose a tag to compare
v3.8.0-beta.5 Pre-release
Pre-release

3.8.0-beta.5

Patch Changes

  • #10999 c1904a78a Thanks @phryneas! - Fix a bug in QueryReference where this.resolve or this.reject might be executed even if undefined.

  • #11018 5618953f3 Thanks @jerelmiller! - useBackgroundQuery now uses its own options type called BackgroundQueryHookOptions rather than reusing SuspenseQueryHookOptions.

  • #11010 1051a9c88 Thanks @alessbell! - Hide queryRef in a Symbol in useBackgroundQuerys return value.

  • #10960 ee407ef97 Thanks @alessbell! - Adds support for returnPartialData and refetchWritePolicy options in useBackgroundQuery hook.

v3.8.0-beta.4

03 Aug 09:55
43c506a
Compare
Choose a tag to compare
v3.8.0-beta.4 Pre-release
Pre-release

3.8.0-beta.4

Patch Changes

  • #10940 1d38f128f Thanks @jerelmiller! - Add support for the skip option in useBackgroundQuery and useSuspenseQuery. Setting this option to true will avoid a network request.

v3.7.16

20 Jun 22:47
2e59045
Compare
Choose a tag to compare

Patch Changes

  • #10806 cb1540504 Thanks @phryneas! - Fix a bug in PersistedQueryLink that would cause it to permanently skip persisted queries after a 400 or 500 status code.

  • #10807 b32369592 Thanks @phryneas! - PersistedQueryLink will now also check for error codes in extensions.

  • #10982 b9be7a814 Thanks @sdeleur-sc! - Update relayStylePagination to avoid populating startCursor when only a single cursor is present under the edges field. Use that cursor only as the endCursor.

  • #10962 772cfa3cb Thanks @jerelmiller! - Remove useGETForQueries option in BatchHttpLink.Options type since it is not supported.

Potentially breaking change in PersistedQueryLink

Previously, if the PersistedQueryLink encountered a single 400 or 500 error, it would stop sending any persisted queries in the future. This allowed you to use the link even if a server had no support for persisted queries.

We have decided to change this behavior, so now the PersistedQueryLink will only stop trying to send query hashes if the server responds with a PERSISTED_QUERY_NOT_SUPPORTED error code as it was unclear whether a 400 or 500 status code was in fact because the server did not support persisted queries.

If you relied on the previous behaviour, maybe because you were communicating with a server that might or might not support persisted queries, but would return with a different kind of error, you can use the disable option callback to override this behavior like this:

createPersistedQueryLink({
  // ... other options ...
  disable({ operation }){
    const { response } = operation.getContext();
    return (
      response &&
      response.status &&
      (response.status === 400 || response.status === 500)
    );
  }
})

Alternatively, consider removing the link entirely when your server does not support persisted queries.

New Contributors

v3.8.0-beta.3

03 Aug 09:55
befc2a3
Compare
Choose a tag to compare
v3.8.0-beta.3 Pre-release
Pre-release

3.8.0-beta.3

Minor Changes

  • #10895 e187866fd Thanks @(author)! - Add generic type parameter for the entity modified in cache.modify. Improves
    TypeScript type inference for that type's fields and values of those fields.

    Example:

    cache.modify<Book>({
      id: cache.identify(someBook),
      fields: {
        title: (title) => {
          // title has type `string`.
          // It used to be `any`.
        },
     => {
          // author has type `Reference | Book["author"]`.
          // It used to be `any`.
        },
      },
    });
  • #10895 e187866fd Thanks @Gelio! - Use unique opaque types for the DELETE and INVALIDATE Apollo cache modifiers.

    This increases type safety, since these 2 modifiers no longer have the any type.
    Moreover, it no longer triggers the @typescript-eslint/no-unsafe-return
    rule
    .

Patch Changes

  • #10951 2e833b2ca Thanks @alessbell! - Improve useBackgroundQuery type interface

  • #10964 f33171506 Thanks @alessbell! - Fixes a bug in BatchHttpLink that removed variables from all requests by default.

  • #10968 b102390b2 Thanks @phryneas! - Use printed query for query deduplication. Cache print calls for GraphQL documents to speed up repeated operations.

  • #10969 525a9317a Thanks @phryneas! - Slightly decrease bundle size and memory footprint of SuspenseCache by changing how cache entries are stored internally.