Releases: apollographql/apollo-client
@apollo/[email protected]
Major Changes
-
#12840
83e132a
Thanks @phryneas! - If you use an incremental delivery handler, you now have to explicitly opt into adding the chunk types to theApolloLink.Result
type.import { Defer20220824Handler } from "@apollo/client/incremental"; declare module "@apollo/client" { export interface TypeOverrides extends Defer20220824Handler.TypeOverrides {} }
-
#12841
65b503f
Thanks @jerelmiller! - Remove theDataMasking
interface exported from@apollo/client
and@apollo/client/masking
.
@apollo/[email protected]
Major Changes
-
#12837
7c49fdc
Thanks @jerelmiller! - You must now opt in to use GraphQL Codegen data masking types when using Apollo Client's data masking feature. By default, Apollo Client now uses an identity type to apply to masked/unmasked types.If you're using GraphQL Codegen to generate masked types, opt into the GraphQL Codegen masked types using declaration merging on the
TypeOverides
interface.import { GraphQLCodegenDataMasking } from "@apollo/client/masking"; declare module "@apollo/client" { export interface TypeOverrides extends GraphQLCodegenDataMasking.TypeOverrides {} }
-
#12837
7c49fdc
Thanks @jerelmiller! - The types mode for data masking has been removed. Adding a types mode to theDataMasking
interface has no effect. Remove themode
key in the module where you declare theDataMasking
type for the@apollo/client
module.As a result, the
Masked
andMaskedDocumentNode
types have also been removed since these have no effect when types are preserved.
@apollo/[email protected]
@apollo/[email protected]
Major Changes
-
#12825
292b949
Thanks @jerelmiller! - TheserializeFetchParameter
helper is no longer exported andJSON.stringify
is used directly. As such, theClientParseError
type has also been removed in favor of throwing any JSON serialize errors directly. -
#12824
0506f12
Thanks @jerelmiller! - Ensure theerror
argument for thedelay
andattempts
functions onRetryLink
are anErrorLike
. -
#12823
19e315e
Thanks @jerelmiller! - Move all 1st party link types into a namespace. -
#12823
19e315e
Thanks @jerelmiller! - TheOperationBatcher
class is no longer exported from@apollo/client/link/batch
. It is an implementation detail ofBatchLink
and should not be relied on directly.
Patch Changes
-
#12824
0506f12
Thanks @jerelmiller! -RetryLink
now emits anext
event instead of anerror
event when encountering a protocol errors for multipart subscriptions when the operation is not retried. This ensures the observable notification remains the same as whenRetryLink
is not used. -
#12819
7ff548d
Thanks @jerelmiller! - update type ofHttpLink.Options.fetchOptions
toRequestInit
-
#12820
fba3d9e
Thanks @jerelmiller! - ThefetchOptions
option provided toHttpLink
andBatchHttpLink
is nowRequestInit
instead ofany
. Thecredentials
option is now aRequestCredentials
type instead of astring
. -
#12823
19e315e
Thanks @jerelmiller! - Fix the type of the argument for thesha256
function forPersistedQueryLink
from...any[]
tostring
. -
#12821
223a409
Thanks @jerelmiller! - Add a deprecation warning toWebSocketLink
.
@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.