Skip to content
This repository has been archived by the owner on Oct 8, 2023. It is now read-only.

Update dependency @apollo/client to ^3.8.4 #344

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Aug 7, 2023

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
@apollo/client (source) ^3.7.12 -> ^3.8.4 age adoption passing confidence

Release Notes

apollographql/apollo-client (@​apollo/client)

v3.8.4

Compare Source

Patch Changes

v3.8.3

Compare Source

Patch Changes

v3.8.2

Compare Source

Patch Changes
  • #​10072 51045c336 Thanks @​Huulivoide! - Fixes race conditions in useReactiveVar that may prevent updates to the reactive variable from propagating through the hook.

  • #​11162 d9685f53c Thanks @​jerelmiller! - Ensures GraphQL errors returned in subscription payloads adhere to the errorPolicy set in client.subscribe(...) calls.

  • #​11134 96492e142 Thanks @​alessbell! - Use separate type imports in useSuspenseQuery and useBackgroundQuery to workaround SWC compiler issue.

  • #​11117 6b8198109 Thanks @​phryneas! - Adds a new devtools registration mechanism and tweaks the mechanism behind the
    "devtools not found" mechanic.

  • #​11186 f1d429f32 Thanks @​jerelmiller! - Fix an issue where race conditions when rapidly switching between variables would sometimes result in the wrong data returned from the query. Specifically this occurs when a query is triggered with an initial set of variables (VariablesA), then triggers the same query with another set of variables (VariablesB) but switches back to the VariablesA before the response for VariablesB is returned. Previously this would result in the data for VariablesB to be displayed while VariablesA was active. The data is for VariablesA is now properly returned.

  • #​11163 a8a9e11e9 Thanks @​bignimbus! - Fix typo in error message: "occured" -> "occurred"

  • #​11180 7d9c481e5 Thanks @​jerelmiller! - Fixes an issue where refetching from useBackgroundQuery via refetch with an error after an error was already fetched would get stuck in a loading state.

v3.8.1

Compare Source

Patch Changes
  • #​11141 c469b1616 Thanks @​jerelmiller! - Remove newly exported response iterator helpers that caused problems on some installs where @types/node was not available.

    IMPORTANT

    The following exports were added in version 3.8.0 that are removed with this patch.

    • isAsyncIterableIterator
    • isBlob
    • isNodeReadableStream
    • isNodeResponse
    • isReadableStream
    • isStreamableBlob

v3.8.0

Compare Source

Minor Changes
Fetching with Suspense 🎉
  • #​10323 64cb88a4b Thanks @​jerelmiller! - Add support for React suspense with a new useSuspenseQuery hook.

    useSuspenseQuery initiates a network request and causes the component calling it to suspend while the request is in flight. It can be thought of as a drop-in replacement for useQuery that allows you to take advantage of React's concurrent features while fetching during render.

    Consider a Dog component that fetches and renders some information about a dog named Mozzarella:

    View code 🐶
    import { Suspense } from "react";
    import { gql, TypedDocumentNode, useSuspenseQuery } from "@​apollo/client";
    
    interface Data {
      dog: {
        id: string;
        name: string;
      };
    }
    
    interface Variables {
      name: string;
    }
    
    const GET_DOG_QUERY: TypedDocumentNode<Data, Variables> = gql`
      query GetDog($name: String) {
        dog(name: $name) {
          id
          name
        }
      }
    `;
    
    function App() {
      return (
        <Suspense fallback={<div>Loading...</div>}>
          <Dog name="Mozzarella" />
        </Suspense>
      );
    }
    
    function Dog({ name }: { name: string }) {
      const { data } = useSuspenseQuery(GET_DOG_QUERY, {
        variables: { name },
      });
    
      return <>Name: {data.dog.name}</>;
    }

    For a detailed explanation of useSuspenseQuery, see our fetching with Suspense reference.

  • #​10755 e3c676deb Thanks @​alessbell! - Feature: adds useBackgroundQuery and useReadQuery hooks

    useBackgroundQuery initiates a request for data in a parent component and returns a QueryReference which is used to read the data in a child component via useReadQuery. If the child component attempts to render before the data can be found in the cache, the child component will suspend until the data is available. On cache updates to watched data, the child component calling useReadQuery will re-render with new data but the parent component will not re-render (as it would, for example, if it were using useQuery to issue the request).

    Consider an App component that fetches a list of breeds in the background while also fetching and rendering some information about an individual dog, Mozzarella:

    View code 🐶
    function App() {
      const [queryRef] = useBackgroundQuery(GET_BREEDS_QUERY);
      return (
        <Suspense fallback={<div>Loading...</div>}>
          <Dog name="Mozzarella" queryRef={queryRef} />
        </Suspense>
      );
    }
    
    function Dog({
      name,
      queryRef,
    }: {
      name: string;
      queryRef: QueryReference<BreedData>;
    }) {
      const { data } = useSuspenseQuery(GET_DOG_QUERY, {
        variables: { name },
      });
      return (
        <>
          Name: {data.dog.name}
          <Suspense fallback={<div>Loading breeds...</div>}>
            <Breeds queryRef={queryRef} />
          </Suspense>
        </>
      );
    }
    
    function Breeds({ queryRef }: { queryRef: QueryReference<BreedData> }) {
      const { data } = useReadQuery(queryRef);
      return data.breeds.map(({ characteristics }) =>
        characteristics.map((characteristic) => (
          <div key={characteristic}>{characteristic}</div>
        ))
      );
    }

    For a detailed explanation of useBackgroundQuery and useReadQuery, see our fetching with Suspense reference.

Document transforms 📑
  • #​10509 79df2c7ba Thanks @​jerelmiller! - Add the ability to specify custom GraphQL document transforms. These transforms are run before reading data from the cache, before local state is resolved, and before the query document is sent through the link chain.

    To register a custom document transform, create a transform using the DocumentTransform class and pass it to the documentTransform option on ApolloClient.

    import { DocumentTransform } from "@&#8203;apollo/client";
    
    const documentTransform = new DocumentTransform((document) => {
      // do something with `document`
      return transformedDocument;
    });
    
    const client = new ApolloClient({ documentTransform: documentTransform });

    For more information on the behavior and API of DocumentTransform, see its reference page in our documentation.

New removeTypenameFromVariables link 🔗
  • #​10853 300957960 Thanks @​jerelmiller! - Introduce the new removeTypenameFromVariables link. This link will automatically remove __typename fields from variables for all operations. This link can be configured to exclude JSON-scalars for scalars that utilize __typename.

    This change undoes some work from #​10724 where __typename was automatically stripped for all operations with no configuration. This was determined to be a breaking change and therefore moved into this link.

    For a detailed explanation of removeTypenameFromVariables, see its API reference.

New skipToken sentinel ⏭️
  • #​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.

    useSuspenseQuery

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

    useBackgroundQuery

    import { skipToken, useBackgroundQuery } from "@&#8203;apollo/client";
    
    function Parent() {
      const [queryRef] = useBackgroundQuery(
        query,
        id ? { variables: { id } } : skipToken
      );
    
      return queryRef ? <Child queryRef={queryRef} /> : null;
    }
    
    function Child({ queryRef }: { queryRef: QueryReference<TData> }) {
      const { data } = useReadQuery(queryRef);
    }

    For a detailed explanation of skipToken, see its API reference.

New error extraction mechanism, smaller bundles 📉
  • #​10887 f8c0b965d Thanks @​phryneas! - Add a new mechanism for Error Extraction to reduce bundle size by including error message texts on an opt-in basis.

    By default, errors will link to an error page with the entire error message.
    This replaces "development" and "production" errors and works without
    additional bundler configuration.

    Bundling the text of error messages and development warnings can be enabled as follows:

    import { loadErrorMessages, loadDevMessages } from "@&#8203;apollo/client/dev";
    if (process.env.NODE_ENV !== "production") {
      loadErrorMessages();
      loadDevMessages();
    }

    For a detailed explanation, see our reference on reducing bundle size.

New @nonreactive directive 🎬
  • #​10722 c7e60f83d Thanks @​benjamn! - Implement a @nonreactive directive for selectively skipping reactive comparisons of query result subtrees.

    The @nonreactive directive can be used to mark query fields or fragment spreads and is used to indicate that changes to the data contained within the subtrees marked @nonreactive should not trigger re-rendering. This allows parent components to fetch data to be rendered by their children without re-rendering themselves when the data corresponding with fields marked as @nonreactive change.

    Consider an App component that fetches and renders a list of ski trails:

    View code 🎿
    const TrailFragment = gql`
      fragment TrailFragment on Trail {
        name
        status
      }
    `;
    
    const ALL_TRAILS = gql`
      query allTrails {
        allTrails {
          id
          ...TrailFragment @&#8203;nonreactive
        }
      }
      ${TrailFragment}
    `;
    
    function App() {
      const { data, loading } = useQuery(ALL_TRAILS);
      return (
        <main>
          <h2>Ski Trails</h2>
          <ul>
            {data?.trails.map((trail) => (
              <Trail key={trail.id} id={trail.id} />
            ))}
          </ul>
        </main>
      );
    }

    The Trail component renders a trail's name and status and allows the user to execute a mutation to toggle the status of the trail between "OPEN" and "CLOSED":

    View code 🎿
    const Trail = ({ id }) => {
      const [updateTrail] = useMutation(UPDATE_TRAIL);
      const { data } = useFragment({
        fragment: TrailFragment,
        from: {
          __typename: "Trail",
          id,
        },
      });
      return (
        <li key={id}>
          {data.name} - {data.status}
          <input
            checked={data.status === "OPEN" ? true : false}
            type="checkbox"
            onChange={(e) => {
              updateTrail({
                variables: {
                  trailId: id,
                  status: e.target.checked ? "OPEN" : "CLOSED",
                },
              });
            }}
          />
        </li>
      );
    };

    Notice that the Trail component isn't receiving the entire trail object via props, only the id which is used along with the fragment document to create a live binding for each trail item in the cache. This allows each Trail component to react to the cache updates for a single trail independently. Updates to a trail's status will not cause the parent App component to rerender since the @nonreactive directive is applied to the TrailFragment spread, a fragment that includes the status field.

    For a detailed explanation, see our @nonreactive reference and @​alessbell's post on the Apollo blog about using @nonreactive with useFragment.

Abort the AbortController signal more granularly 🛑
  • #​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.

useFragment drops its experimental label 🎓
  • #​10916 ea75e18de Thanks @​alessbell! - Remove experimental labels.

    useFragment, introduced in 3.7.0 as useFragment_experimental, is no longer an experimental API 🎉 We've removed the _experimental suffix from its named export and have made a number of improvements.

    For a detailed explanation, see our useFragment reference and @​alessbell's post on the Apollo blog about using useFragment with @nonreactive for improved performance when rendering lists.

    useFragment improvements
    • #​10765 35f36c5aa Thanks @​phryneas! - More robust types for the data property on UseFragmentResult. When a partial result is given, the type is now correctly set to Partial<TData>.

    • #​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.

    • #​10836 6794893c2 Thanks @​phryneas! - Remove the deprecated returnPartialData option from useFragment hook.

More Minor Changes

  • #​10895 e187866fd Thanks @​Gelio! - 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
    .

  • #​10340 4f73c5ca1 Thanks @​alessbell! - Avoid calling useQuery onCompleted for cache writes

  • #​10527 0cc7e2e19 Thanks @​phryneas! - Remove the query/mutation/subscription option from hooks that already take that value as their first argument.

  • #​10506 2dc2e1d4f Thanks @​phryneas! - prevent accidental widening of inferred TData and TVariables generics for query hook option arguments

  • #​10521 fbf729414 Thanks @​benjamn! - Simplify __DEV__ polyfill to use imports instead of global scope

  • #​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.

  • #​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.

  • #​10346 3bcfc42d3 Thanks @​jerelmiller! - Add the ability to allow @client fields to be sent to the link chain.

  • #​10567 c2ce6496c Thanks @​benjamn! - Allow ApolloCache implementations to specify default value for assumeImmutableResults client option, improving performance for applications currently using InMemoryCache without configuring new ApolloClient({ assumeImmutableResults: true })

  • #​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

  • #​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.

  • #​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.

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

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

  • #​10594 f221b5e8f Thanks @​phryneas! - Add a suspenseCache option to useSuspenseQuery

  • #​10700 12e37f46f Thanks @​jerelmiller! - Add a queryKey option to useSuspenseQuery that allows the hook to create a unique subscription instance.

  • #​10724 e285dfd00 Thanks @​jerelmiller! - Automatically strips __typename fields from variables sent to the server when using HttpLink, BatchHttpLink, or GraphQLWsLink. This allows GraphQL data returned from a query to be used as an argument to a subsequent GraphQL operation without the need to strip the __typename in user-space.

  • #​10957 445164d21 Thanks @​phryneas! - Use React.version as key for shared Contexts.

  • #​10635 7df51ee19 Thanks @​jerelmiller! - Fix an issue where cache updates would not propagate to useSuspenseQuery while in strict mode.

  • #​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.

  • #​10869 ba1d06166 Thanks @​phryneas! - Ensure Context value stability when rerendering ApolloProvider with the same client and/or suspenseCache prop

  • #​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' .

  • #​10657 db305a800 Thanks @​jerelmiller! - Return networkStatus in the useSuspenseQuery result.

  • #​10937 eea44eb87 Thanks @​jerelmiller! - Moves DocumentTransform to the utilities sub-package to avoid a circular dependency between the core and cache sub-packages.

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

  • #​10651 8355d0e1e Thanks @​jerelmiller! - Fixes an issue where useSuspenseQuery would not respond to cache updates when using a cache-first fetchPolicy after the hook was mounted with data already in the cache.

  • #​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)

  • #​10852 27fbdb3f9 Thanks @​phryneas! - Chore: Add ESLint rule for consistent type imports, apply autofix

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

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

  • #​10672 932252b0c Thanks @​jerelmiller! - Fix the compatibility between useSuspenseQuery and React's useDeferredValue and startTransition APIs to allow React to show stale UI while the changes to the variable cause the component to suspend.

Breaking change

nextFetchPolicy support has been removed from useSuspenseQuery. If you are using this option, remove it, otherwise it will be ignored.

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.

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

  • #​10809 49d28f764 Thanks @​jerelmiller! - Fixed the ability to use refetch and fetchMore with React's startTransition. The hook will now behave correctly by allowing React to avoid showing the Suspense fallback when these functions are wrapped by startTransition. This change deprecates the suspensePolicy option in favor of startTransition.

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

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

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

  • #​10872 96b4f8837 Thanks @​phryneas! - The "per-React-Version-Singleton" ApolloContext is now stored on globalThis, not React.createContext, and throws an error message when accessed from React Server Components.

  • #​10450 f8bc33387 Thanks @​jerelmiller! - Add support for the subscribeToMore and client fields returned in the useSuspenseQuery result.

v3.7.17

Compare Source

Patch Changes

v3.7.16

Compare Source

Patch Changes

v3.7.15

Compare Source

Patch Changes
  • #​10891 ab42a5c08 Thanks @​laverdet! - Fixes a bug in how multipart responses are read when using @defer. When reading a multipart body, HttpLink no longer attempts to parse the boundary (e.g. "---" or other boundary string) within the response data itself, only when reading the beginning of each mulitpart chunked message.

  • #​10789 23a4e1578 Thanks @​phryneas! - Fix a bug where other fields could be aliased to __typename or id, in which case an incoming result would be merged into the wrong cache entry.

v3.7.14

Compare Source

Patch Changes
  • #​10764 1b0a61fe5 Thanks @​phryneas! - Deprecate useFragment returnPartialData option

  • #​10810 a6252774f Thanks @​dleavitt! - Fix type signature of ServerError.

    In <3.7 HttpLink and BatchHttpLink would return a ServerError.message of e.g. "Unexpected token 'E', \"Error! Foo bar\" is not valid JSON" and a ServerError.result of undefined in the case where a server returned a >= 300 response code with a response body containing a string that could not be parsed as JSON.

    In >=3.7, message became e.g. Response not successful: Received status code 302 and result became the string from the response body, however the type in ServerError.result was not updated to include the string type, which is now properly reflected.

v3.7.13

Compare Source

Patch Changes
  • #​10805 a5503666c Thanks @​phryneas! - Fix a potential memory leak in SSR scenarios when many persistedQuery instances were created over time.

  • #​10718 577c68bdd Thanks @​Hsifnus! - Delay Concast subscription teardown slightly in useSubscription to prevent unexpected Concast teardown when one useSubscription hook tears down its in-flight Concast subscription immediately followed by another useSubscription hook reusing and subscribing to that same Concast


Configuration

📅 Schedule: Branch creation - "before 7am on Tuesday,before 7am on Wednesday" in timezone Australia/Melbourne, Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@changeset-bot
Copy link

changeset-bot bot commented Aug 7, 2023

⚠️ No Changeset found

Latest commit: f287a6c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@renovate renovate bot changed the title Update dependency @apollo/client to ^3.8.0 Update dependency @apollo/client to ^3.8.1 Aug 14, 2023
@renovate renovate bot force-pushed the renovate/apollo-graphql-packages branch from 439bb22 to 4d6b9df Compare August 14, 2023 17:29
@renovate renovate bot changed the title Update dependency @apollo/client to ^3.8.1 Update dependency @apollo/client to ^3.8.2 Sep 4, 2023
@renovate renovate bot force-pushed the renovate/apollo-graphql-packages branch from 4d6b9df to c6d6a13 Compare September 4, 2023 17:21
@renovate renovate bot changed the title Update dependency @apollo/client to ^3.8.2 Update dependency @apollo/client to ^3.8.3 Sep 5, 2023
@renovate renovate bot force-pushed the renovate/apollo-graphql-packages branch from c6d6a13 to 765c498 Compare September 5, 2023 19:58
@renovate renovate bot changed the title Update dependency @apollo/client to ^3.8.3 Update dependency @apollo/client to ^3.8.4 Sep 19, 2023
@renovate renovate bot force-pushed the renovate/apollo-graphql-packages branch from 765c498 to f287a6c Compare September 19, 2023 19:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants