Releases: apollographql/apollo-client
@apollo/[email protected]
Minor Changes
- #13043
65e66caThanks @jerelmiller! - Supportheaderstransport for enhanced client awareness.
@apollo/[email protected]
Minor Changes
- #13038
109efe7Thanks @jerelmiller! - Add thefromoption toreadFragment,watchFragment, andupdateFragment.
@apollo/[email protected]
Patch Changes
- #13026
05eee67Thanks @jerelmiller! - Reduce the number of observables created bywatchFragmentby reusing existing observables as much as possible. This should improve performance when watching the same item in the cache multiple times after a cache update occurs.
@apollo/[email protected]
Patch Changes
-
#13010
7627000Thanks @jerelmiller! - Fix an issue where errors parsed from incremental chunks inErrorLinkmight throw when using theGraphQL17Alpha9Handler. -
#13010
7627000Thanks @jerelmiller! - Handle@streampayloads that send multiple items in the same chunk when using theDefer20220824Handler. -
#13010
7627000Thanks @jerelmiller! - Handle an edge case with theDefer20220824Handlerwhere an error for a@streamitem that bubbles to the@streamboundary (such as an item returningnullfor a non-null array item) would write items from future chunks to the wrong array index. In these cases, the@streamfield is no longer processed and future updates to the field are ignored. This prevents runtime errors that TypeScript would otherwise not be able to catch.
@apollo/[email protected]
@apollo/[email protected]
@apollo/[email protected]
Patch Changes
- #12993
8f3bc9bThanks @jerelmiller! - Fix an issue where switching from options withvariablestoskipTokenwithuseSuspenseQueryanduseBackgroundQuerywould create a newObservableQuery. This could cause unintended refetches wherevariableswere absent in the request when the query was referenced withrefetchQueries.
@apollo/[email protected]
@apollo/[email protected]
Minor Changes
-
#12971
d11eb40Thanks @jerelmiller! - Add support forfrom: nullinclient.watchFragmentandcache.watchFragment. Whenfromisnull, the emitted result is:{ data: null, dataState: "complete", complete: true, }
-
#12971
d11eb40Thanks @jerelmiller! - Add support for arrays withuseFragment,useSuspenseFragment, andclient.watchFragment. This allows the ability to use a fragment to watch multiple entities in the cache. Passing an array tofromwill returndataas an array where each array index corresponds to the index in thefromarray.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
d11eb40Thanks @jerelmiller! - Add agetCurrentResultfunction to the observable returned byclient.watchFragmentandcache.watchFragmentthat 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
d11eb40Thanks @jerelmiller! - Deduplicate watches created byuseFragment,client.watchFragment, andcache.watchFragmentthat contain the same fragment, variables, and identifier. This should improve performance in situations where auseFragmentor aclient.watchFragmentis used to watch the same object in multiple places of an application. -
#12982
5c56b32Thanks @jerelmiller! - Ignore top-leveldatavalues on subsequent chunks in incremental responses. -
#12982
5c56b32Thanks @jerelmiller! - Fix theDefer20220824Handler.SubsequentResulttype to match theFormattedSubsequentIncrementalExecutionResulttype in[email protected]. -
#12973
072da24Thanks @jerelmiller! - Update theacceptheader used with theGraphQL17Alpha9Handlertomultipart/mixed;incrementalSpec=v0.2to ensure the newest incremental delivery format is requested. -
#12971
d11eb40Thanks @jerelmiller! -DeepPartial<Array<TData>>now returnsArray<DeepPartial<TData>>instead ofArray<DeepPartial<TData | undefined>>.
@apollo/[email protected]
Minor Changes
-
#12959
556e837Thanks @jerelmiller! - You can now provide a callback function as thecontextoption on themutatefunction returned byuseMutation. The callback function is called with the value of thecontextoption provided to theuseMutationhook. This is useful if you'd like to merge the context object provided to theuseMutationhook with a value provided to themutatefunction.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 }), }); } // ... }
Patch Changes
- #12954
1c82eafThanks @jerelmiller! - Ensure an error is thrown when@streamis detected and anincrementalDeliveryhandler is not configured.