Releases: apollographql/apollo-client
@apollo/[email protected]
Major Changes
-
#12809
e2a0be8
Thanks @jerelmiller! -operation.getContext
now returns aReadonly<OperationContext>
type. -
#12809
e2a0be8
Thanks @jerelmiller! - TheApolloLink.Request
(i.e.GraphQLRequest
) passed toApolloLink.execute
no longer acceptsoperationName
andoperationType
options. These properties are derived from thequery
and set on the returnedApolloLink.Operation
type. -
#12808
8e31a23
Thanks @phryneas! - HTTP Multipart handling will now throw an error if the connection closed before the final boundary has been received.
Data after the final boundary will be ignored. -
#12809
e2a0be8
Thanks @jerelmiller! -operation.operationType
is now a non-nullOperationTypeNode
. It is now safe to compare this value without having to check forundefined
. -
#12809
e2a0be8
Thanks @jerelmiller! -operation.operationName
is now set asstring | undefined
whereundefined
represents an anonymous query. PreviouslyoperationName
would return an empty string as theoperationName
for anonymous queries. -
#12809
e2a0be8
Thanks @jerelmiller! - Theconcat
,from
, andsplit
functions onApollLink
no longer support a plain request handler function. Please wrap the request handler withnew ApolloLink
.const link = new ApolloLink(/* ... */); link.concat( - (operation, forward) => forward(operation), + new ApolloLink((operation, forward) => forward(operation)), );
-
#12809
e2a0be8
Thanks @jerelmiller! -transformOperation
andvalidateOperation
have been removed and are no longer exported from@apollo/client/link/utils
. These utilities have been merged into the implementation ofcreateOperation
. As a result,createOperation
now returns a well-formedOperation
object. PreviouslycreateOperation
relied on an external call totransformOperation
to provide a well-formedOperation
type. If you usecreateOperation
directly, remove the calls totransformOperation
andvalidateOperation
and pass the request directly. -
#12809
e2a0be8
Thanks @jerelmiller! - The request handler provided toApolloLink
must now return anObservable
.null
is no longer supported as a valid return value. If you rely onnull
so thatApolloLink
provides an empty observable, use theEMPTY
observable from RxJS instead:import { ApolloLink } from "@apollo/client"; + import { EMPTY } from "rxjs"; const link = new ApolloLink((operation, forward) => { - return null; + return EMPTY; });
If you have a custom link that overrides the
request
method, removenull
from the return signature:class MyCustomLink extends ApolloLink { request( operation: ApolloLink.Operation, forward: ApolloLink.ForwardFunction, - ): Observable<ApolloLink.Result> | null { + ): Observable<ApolloLink.Result> { // implementation } }
-
#12809
e2a0be8
Thanks @jerelmiller! -createOperation
no longer acceptscontext
as the first argument. Instead make surecontext
is set as thecontext
property on the request passed tocreateOperation
.createOperation( - startingContext, - { query }, + { query, context: startingContext }, { client } );
-
#12809
e2a0be8
Thanks @jerelmiller! - Remove theTVariables
generic argument on theGraphQLRequest
type. -
#12809
e2a0be8
Thanks @jerelmiller! - The context object returned fromoperation.getContext()
is now frozen to prevent mutable changes to the object which could result in subtle bugs. This applies to thepreviousContext
object passed to theoperation.setContext()
callback as well. -
#12809
e2a0be8
Thanks @jerelmiller! - Theforward
function passed to the request handler is now always provided torequest
and no longer optional. If you create custom links by subclassingApolloLink
, theforward
function no longer needs to be optional:class CustomLink extends ApolloLink { request( operation: ApolloLink.Operation, // This no longer needs to be typed as optional forward: ApolloLink.ForwardFunction ) { // ... } }
As a result of this change,
ApolloLink
no longer detects terminating links by checking function arity on the request handler. This means using methods such asconcat
on a terminating link no longer emit a warning. On the flip side, if the terminating link calls theforward
function, a warning is emitted and an observable that immediately completes is returned which will result in an error from Apollo Client.
Minor Changes
-
#12809
e2a0be8
Thanks @jerelmiller! -ApolloLink
'sconcat
method now accepts multiple links to concatenate together.const first = new ApolloLink(); const link = first.concat(second, third, fouth);
-
#12809
e2a0be8
Thanks @jerelmiller! - Many of the types exported from@apollo/client/link
now live on theApolloLink
namespace. The old types are now deprecated in favor of the namespaced types.FetchResult
->ApolloLink.Result
GraphQLRequest
->ApolloLink.Request
NextLink
->ApolloLink.ForwardFunction
Operation
->ApolloLink.Operation
RequestHandler
->ApolloLink.RequestHandler
-
#12809
e2a0be8
Thanks @jerelmiller! - The staticApolloLink.concat
method is now deprecated in favor ofApolloLink.from
.ApolloLink.concat
is now an alias forApolloLink.from
so preferApolloLink.from
instead.
Patch Changes
-
#12809
e2a0be8
Thanks @jerelmiller! - The individualempty
,concat
,from
andsplit
functions exported from@apollo/client/link
are now deprecated in favor of using the static functions instead.import { ApolloLink, - concat, - empty, - from, - split, } from "@apollo/client/link"; - concat(first, second); + ApolloLink.concat(first, second); - empty(); + ApolloLink.empty(); - from([first, second]); + ApolloLink.from([first, second]); - split( + ApolloLink.split( (operation) => /* */, first, second );
v3.13.9
@apollo/[email protected]
Major Changes
-
#12787
8ce31fa
Thanks @phryneas! - RemoveDataProxy
namespace and interface. -
#12788
4179446
Thanks @phryneas! -TVariables
now alwaysextends OperationVariables
in all interfaces. -
#12802
e2b51b3
Thanks @jerelmiller! - Disallow themutation
option for themutate
function returned fromuseMutation
. -
#12787
8ce31fa
Thanks @phryneas! - Generic arguments forCache.ReadOptions
were flipped fromTVariables, TData
toTData, TVariables
. -
#12793
24e98a1
Thanks @phryneas! -ApolloConsumer
has been removed - please useuseApolloClient
instead.
Patch Changes
- #12782
742b3a0
Thanks @jerelmiller! - MoveApolloClient
,ObservableQuery
, andApolloCache.watchFragment
method options and result types into namespaces. The old types are now exported as deprecated.
@apollo/[email protected]
Major Changes
-
#12776
bce9b74
Thanks @jerelmiller! - Report masked fragments as complete even when a nested masked fragment contains partial data. -
#12774
511b4f3
Thanks @jerelmiller! - Apply document transforms before reading data from the cache forclient.readQuery
,client.readFragment
,client.watchFragment
,useFragment
, anduseSuspenseFragment
.NOTE: This change does not affect the equivalent
cache.*
APIs. To read data from the cache without first running document transforms, runcache.readQuery
,cache.readFragment
, etc.
Minor Changes
- #12776
bce9b74
Thanks @jerelmiller! - AdddataState
to the value emitted fromclient.watchFragment
.
Patch Changes
-
#12776
bce9b74
Thanks @jerelmiller! -cache.watchFragment
now returns anUnmasked<TData>
result sincecache.watchFragment
does not mask fragment spreads. -
#12370
0517163
Thanks @phryneas! -InMemoryCache
: Fields with an empty argument object are now saved the same way as fields without arguments.Previously, it was possible that the reponses for these two queries would be stored differently in the cache:
query PlainAccess { myField }
would be stored as
myField
andquery AccessWithoutOptionalArgument($optional: String) { myField(optional: $optional) }
would be stored as
myField({"optional":"Foo"})
if called with{optional: "Foo"}
and asmyField({})
if called without the optional argument.The cases
myField
andmyField({})
are equivalent from the perspective of a GraphQL server, and so in the future both of these will be stored asmyField
in the cache. -
#12775
454ec78
Thanks @jerelmiller! - Don't exportgql
from@apollo/client/react
entrypoint. Import from@apollo/client
instead. -
#12761
db6f7c3
Thanks @phryneas! - Deprecate second argument toreadFragment
andreadQuery
-optimistic
should be passed as part of the object in the first argument instead.
@apollo/[email protected]
Patch Changes
- #12775
454ec78
Thanks @jerelmiller! - Don't exportgql
from@apollo/client/react
entrypoint. Import from@apollo/client
instead.
@apollo/[email protected]
v3.14.0-rc.0
Minor Changes
- #12763
5de6a3d
Thanks @jerelmiller! - Version bump only to release latest asrc
.
v3.14.0-alpha.1
Minor Changes
-
#12752
8b779b4
Thanks @jerelmiller! - Add deprecations and warnings to remaining APIs changed in Apollo Client 4.0. -
#12751
567cad8
Thanks @jerelmiller! - Add@deprecated
tags to all properties returned from any query API (e.g.client.query
,observableQuery.refetch
, etc.),client.mutate
, andclient.subscribe
that are no longer available in Apollo Client 4.0. -
#12751
567cad8
Thanks @jerelmiller! - Warn when using astandby
fetch policy withclient.query
.
@apollo/[email protected]
Major Changes
-
#12731
0198870
Thanks @phryneas! - Ship React Compiler compiled React hooks in@apollo/client/react/compiled
.We now ship a React-Compiler compiled version of the React hooks in
@apollo/client/react/compiled
.This entry point contains everything that
@apollo/client/react
does,
so you can use it as a drop-in replacement in your whole application
if you choose to use the compiled hooks.
Minor Changes
- #12753
b85818d
Thanks @jerelmiller! - Renamedclient.reFetchObservableQueries
toclient.refetchObservableQueries
.
client.reFetchObservableQueries
is still available as an alias, but is now
deprecated and will be removed in a future major version.
v3.14.0-alpha.0
Minor Changes
-
#12746
0bcd2f4
Thanks @jerelmiller! - Add warnings and deprecations for options and methods for all React APIs. -
#12746
0bcd2f4
Thanks @jerelmiller! - AddpreloadQuery.toPromise(queryRef)
as a replacement forqueryRef.toPromise()
.queryRef.toPromise()
has been removed in Apollo Client 4.0 in favor ofpreloadQuery.toPromise
and is now considered deprecated. -
#12736
ea89440
Thanks @jerelmiller! - Add deprecations and deprecation warnings forApolloClient
options and methods. -
#12459
1c5a031
Thanks @jerelmiller! - ResetaddTypenameTransform
andfragments
caches when callingcache.gc()
only whenresetResultCache
istrue
. -
#12743
92ad409
Thanks @jerelmiller! - Add deprecations and warnings foraddTypename
inInMemoryCache
andMockedProvider
. -
#12743
92ad409
Thanks @jerelmiller! - Add deprecations and warnings forcanonizeResults
.