Repository navigation
Releases
@apollo/client@4.3.9
Patch Changes
-
#13539
1682553Thanks @jerelmiller! - Fix accidental widening ofTVariablestype in some APIs that inferredTVariablesfrom thevariablesoption.TVariablesis now inferred only from theTypedDocumentNode.Affected APIs include:
client.readFragmentclient.writeFragmentclient.watchFragmentclient.readQueryclient.writeQuerycache.readFragmentcache.writeFragmentcache.updateFragmentcache.watchFragmentcache.readQuerycache.writeQuerycache.updateQuery
@apollo/client@4.4.0-alpha.1
Minor Changes
-
#13522
6f94cfbThanks @jerelmiller! - Fragment APIs now read fragment arguments and operation variables from the object passed tofrom. When you pass an object from a query result, you no longer need to passvariablesto read the fragment with the correct values.const fragment = gql` fragment UserCard($avatarSize: Int) on User { id avatar(size: $avatarSize) } `; const query = gql` query GetUsers($friendAvatarSize: Int) { currentUser { ...UserCard(avatarSize: 96) friends { ...UserCard(avatarSize: $friendAvatarSize) } } } `; const { data } = useQuery(query, { variables: { friendAvatarSize: 32 } }); // Reads the avatar with `size: 96` useFragment({ fragment, from: data.currentUser }); // Reads the avatars with `size: 32` useFragment({ fragment, from: data.currentUser.friends });
This works with
useFragment,useSuspenseFragment,watchFragment,readFragment,writeFragment, andupdateFragment. The same applies to fragments that use operation variables without fragment arguments. -
#13521
7bd29dbThanks @phryneas! -CombinedGraphQLErrorsandCombinedProtocolErrorsnow extendAggregateError.
This means that you will need to use at leastlib: ["es2021"]orlib: ["es2021.promise"]in your TypeScript configuration.
@apollo/client@4.4.0-alpha.0
Minor Changes
-
#13508
c1558e3Thanks @jerelmiller! - Support GraphQL 17 experimental fragment arguments. Fragment definitions can now include variable definitions, and fragment spreads can pass arguments for them.fragment UserFragment($avatarSize: Int!) on User { id avatar(size: $avatarSize) }
Arguments can be passed to the fragment where it's used:
query CurrentUserQuery($friendAvatarSize: Int!) { currentUser { id ...UserFragment(avatarSize: 32) friends { id ...UserFragment(avatarSize: $friendAvatarSize) } } }
You must enable experimental fragment arguments to use this feature:
import { enableExperimentalFragmentVariables } from "@apollo/client"; enableExperimentalFragmentVariables();
[!NOTE]
This MUST be called before any GraphQL documents are parsed. We recommend calling this in your application's entry file.
@apollo/client@4.3.8
@apollo/client@4.3.7
Patch Changes
-
#13518
b302e5aThanks @jerelmiller! - Fix an issue where anAbortErrorwas thrown byuseReadQuerywhen auseBackgroundQueryquery is skipped, itsuseReadQuerycomponent unmounts, and the query is then re-enabled in the same render thatuseReadQuerymounts again. -
#13516
d7cb685Thanks @trevor-scheer! - Fix a race when chainingrefetchandfetchMorecalls withuseSuspenseQueryinside React transitions.For example, an app can refresh the first page of a list with
refetch(), then immediately load the next page withfetchMore()from the refetch promise's.thencallback. A timer from the completed refetch could makeuseTransition'sisPendingbecomefalsebefore the next page arrived, hiding the pending indicator while the list still showed only the first page. Keep the transition pending until the next page is available. This also applies when the first request is anotherfetchMore().
@apollo/client@4.3.6
Patch Changes
-
#13484
9462324Thanks @SunilRathod27! - Exclude"partial"from thedataStateunion returned fromuseQuery,useLazyQuery,useSuspenseQuery,useBackgroundQuery,useLoadableQuery, andpreloadQuery(createQueryPreloader) whenfetchPolicyis"no-cache". This means thatdataStateis never"partial"whenfetchPolicyis"no-cache", regardless of whetherreturnPartialDataistrueorfalse. -
#13486
165aa72Thanks @phryneas! - Pass coerced scalars intorefetchQueries,updateQueriesandupdatemutation callback options -
#13487
237a2a1Thanks @phryneas! - Introduce a warning for missingpossibleTypesthat might lead to data loss. -
#13486
165aa72Thanks @phryneas! - Coerce scalars in no-cache mutations
@apollo/client@4.3.5
Patch Changes
-
#13498
04b12e5Thanks @jerelmiller! - Fix an issue where custom scalar values that are not JSON-serializable caused errors. These values are properly serialized when used as input forvariablesor when used as a key field value so that cache writes and calls tocache.identifysucceed. -
#13500
a23ea85Thanks @jerelmiller! - Require thevariablesoption inuseFragmentwhen the fragment has required variables. This matches the behavior ofuseSuspenseFragmentand the query hooks. -
#13501
303d80fThanks @kgssystem! - Parse custom scalar fields in subscription results when using theno-cachefetch policy.
@apollo/client@4.3.4
Patch Changes
-
#13497
41d604cThanks @jerelmiller! - Fix an issue where a list field selected more than once with different selection sets lost the fields that only one of the selections included while a@deferboundary elsewhere in the query was still pending when using theGraphQL17Alpha9Handler. The results of all selections of the list field are now merged. -
#13457
22746bbThanks @phryneas! - Fixed a bug wherestreamFieldInfomight not have been passed into custom merge functions for
@streamdirectives that had an aliased field in the path. -
#13457
22746bbThanks @phryneas! - FixMissing fielderrors being logged when writing@deferresults where a parent field is selected both inside and outside of a deferred fragment. Fields whose@deferboundary has not been delivered from the network are no longer reported as missing. -
#13453
9bb3a41Thanks @wassim-k! - Unregister the watch when an immediatecache.watchbroadcast throws. Previously the watch was added to the cache before its first read, and a read that threw left the watch registered while the caller never received the unsubscribe function, so it could not be removed and every later broadcast ran into the same failing read. -
#13457
22746bbThanks @phryneas! -Defer20220824Handler: fix a situation wheredataStatewould show up ascompletedwith incremental errors instead of stayingstreaming.
@apollo/client@4.3.3
@apollo/client@4.3.2
Patch Changes
- #13467
7786771Thanks @SSpirate11! - Fix an unhandledAbortErrorpromise rejection that occurred when unsubscribing from a multipart HTTP subscription.