Releases: apollographql/apollo-client
@apollo/[email protected]
@apollo/[email protected]
Major Changes
-
#12840
83e132aThanks @phryneas! - If you use an incremental delivery handler, you now have to explicitly opt into adding the chunk types to theApolloLink.Resulttype.import { Defer20220824Handler } from "@apollo/client/incremental"; declare module "@apollo/client" { export interface TypeOverrides extends Defer20220824Handler.TypeOverrides {} }
-
#12841
65b503fThanks @jerelmiller! - Remove theDataMaskinginterface exported from@apollo/clientand@apollo/client/masking.
@apollo/[email protected]
Major Changes
-
#12837
7c49fdcThanks @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
TypeOveridesinterface.import { GraphQLCodegenDataMasking } from "@apollo/client/masking"; declare module "@apollo/client" { export interface TypeOverrides extends GraphQLCodegenDataMasking.TypeOverrides {} }
-
#12837
7c49fdcThanks @jerelmiller! - The types mode for data masking has been removed. Adding a types mode to theDataMaskinginterface has no effect. Remove themodekey in the module where you declare theDataMaskingtype for the@apollo/clientmodule.As a result, the
MaskedandMaskedDocumentNodetypes have also been removed since these have no effect when types are preserved.
@apollo/[email protected]
@apollo/[email protected]
Major Changes
-
#12825
292b949Thanks @jerelmiller! - TheserializeFetchParameterhelper is no longer exported andJSON.stringifyis used directly. As such, theClientParseErrortype has also been removed in favor of throwing any JSON serialize errors directly. -
#12824
0506f12Thanks @jerelmiller! - Ensure theerrorargument for thedelayandattemptsfunctions onRetryLinkare anErrorLike. -
#12823
19e315eThanks @jerelmiller! - Move all 1st party link types into a namespace. -
#12823
19e315eThanks @jerelmiller! - TheOperationBatcherclass is no longer exported from@apollo/client/link/batch. It is an implementation detail ofBatchLinkand should not be relied on directly.
Patch Changes
-
#12824
0506f12Thanks @jerelmiller! -RetryLinknow emits anextevent instead of anerrorevent when encountering a protocol errors for multipart subscriptions when the operation is not retried. This ensures the observable notification remains the same as whenRetryLinkis not used. -
#12819
7ff548dThanks @jerelmiller! - update type ofHttpLink.Options.fetchOptionstoRequestInit -
#12820
fba3d9eThanks @jerelmiller! - ThefetchOptionsoption provided toHttpLinkandBatchHttpLinkis nowRequestInitinstead ofany. Thecredentialsoption is now aRequestCredentialstype instead of astring. -
#12823
19e315eThanks @jerelmiller! - Fix the type of the argument for thesha256function forPersistedQueryLinkfrom...any[]tostring. -
#12821
223a409Thanks @jerelmiller! - Add a deprecation warning toWebSocketLink.
@apollo/[email protected]
Major Changes
-
#12809
e2a0be8Thanks @jerelmiller! -operation.getContextnow returns aReadonly<OperationContext>type. -
#12809
e2a0be8Thanks @jerelmiller! - TheApolloLink.Request(i.e.GraphQLRequest) passed toApolloLink.executeno longer acceptsoperationNameandoperationTypeoptions. These properties are derived from thequeryand set on the returnedApolloLink.Operationtype. -
#12808
8e31a23Thanks @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
e2a0be8Thanks @jerelmiller! -operation.operationTypeis now a non-nullOperationTypeNode. It is now safe to compare this value without having to check forundefined. -
#12809
e2a0be8Thanks @jerelmiller! -operation.operationNameis now set asstring | undefinedwhereundefinedrepresents an anonymous query. PreviouslyoperationNamewould return an empty string as theoperationNamefor anonymous queries. -
#12809
e2a0be8Thanks @jerelmiller! - Theconcat,from, andsplitfunctions onApollLinkno 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
e2a0be8Thanks @jerelmiller! -transformOperationandvalidateOperationhave been removed and are no longer exported from@apollo/client/link/utils. These utilities have been merged into the implementation ofcreateOperation. As a result,createOperationnow returns a well-formedOperationobject. PreviouslycreateOperationrelied on an external call totransformOperationto provide a well-formedOperationtype. If you usecreateOperationdirectly, remove the calls totransformOperationandvalidateOperationand pass the request directly. -
#12809
e2a0be8Thanks @jerelmiller! - The request handler provided toApolloLinkmust now return anObservable.nullis no longer supported as a valid return value. If you rely onnullso thatApolloLinkprovides an empty observable, use theEMPTYobservable 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
requestmethod, removenullfrom the return signature:class MyCustomLink extends ApolloLink { request( operation: ApolloLink.Operation, forward: ApolloLink.ForwardFunction, - ): Observable<ApolloLink.Result> | null { + ): Observable<ApolloLink.Result> { // implementation } } -
#12809
e2a0be8Thanks @jerelmiller! -createOperationno longer acceptscontextas the first argument. Instead make surecontextis set as thecontextproperty on the request passed tocreateOperation.createOperation( - startingContext, - { query }, + { query, context: startingContext }, { client } );
-
#12809
e2a0be8Thanks @jerelmiller! - Remove theTVariablesgeneric argument on theGraphQLRequesttype. -
#12809
e2a0be8Thanks @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 thepreviousContextobject passed to theoperation.setContext()callback as well. -
#12809
e2a0be8Thanks @jerelmiller! - Theforwardfunction passed to the request handler is now always provided torequestand no longer optional. If you create custom links by subclassingApolloLink, theforwardfunction 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,
ApolloLinkno longer detects terminating links by checking function arity on the request handler. This means using methods such asconcaton a terminating link no longer emit a warning. On the flip side, if the terminating link calls theforwardfunction, a warning is emitted and an observable that immediately completes is returned which will result in an error from Apollo Client.
Minor Changes
-
#12809
e2a0be8Thanks @jerelmiller! -ApolloLink'sconcatmethod now accepts multiple links to concatenate together.const first = new ApolloLink(); const link = first.concat(second, third, fouth);
-
#12809
e2a0be8Thanks @jerelmiller! - Many of the types exported from@apollo/client/linknow live on theApolloLinknamespace. The old types are now deprecated in favor of the namespaced types.FetchResult->ApolloLink.ResultGraphQLRequest->ApolloLink.RequestNextLink->ApolloLink.ForwardFunctionOperation->ApolloLink.OperationRequestHandler->ApolloLink.RequestHandler
-
#12809
e2a0be8Thanks @jerelmiller! - The staticApolloLink.concatmethod is now deprecated in favor ofApolloLink.from.ApolloLink.concatis now an alias forApolloLink.fromso preferApolloLink.frominstead.
Patch Changes
-
#12809
e2a0be8Thanks @jerelmiller! - The individualempty,concat,fromandsplitfunctions exported from@apollo/client/linkare 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
8ce31faThanks @phryneas! - RemoveDataProxynamespace and interface. -
#12788
4179446Thanks @phryneas! -TVariablesnow alwaysextends OperationVariablesin all interfaces. -
#12802
e2b51b3Thanks @jerelmiller! - Disallow themutationoption for themutatefunction returned fromuseMutation. -
#12787
8ce31faThanks @phryneas! - Generic arguments forCache.ReadOptionswere flipped fromTVariables, TDatatoTData, TVariables. -
#12793
24e98a1Thanks @phryneas! -ApolloConsumerhas been removed - please useuseApolloClientinstead.
Patch Changes
- #12782
742b3a0Thanks @jerelmiller! - MoveApolloClient,ObservableQuery, andApolloCache.watchFragmentmethod options and result types into namespaces. The old types are now exported as deprecated.
@apollo/[email protected]
Major Changes
-
#12776
bce9b74Thanks @jerelmiller! - Report masked fragments as complete even when a nested masked fragment contains partial data. -
#12774
511b4f3Thanks @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
bce9b74Thanks @jerelmiller! - AdddataStateto the value emitted fromclient.watchFragment.
Patch Changes
-
#12776
bce9b74Thanks @jerelmiller! -cache.watchFragmentnow returns anUnmasked<TData>result sincecache.watchFragmentdoes not mask fragment spreads. -
#12370
0517163Thanks @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
myFieldandmyField({})are equivalent from the perspective of a GraphQL server, and so in the future both of these will be stored asmyFieldin the cache. -
#12775
454ec78Thanks @jerelmiller! - Don't exportgqlfrom@apollo/client/reactentrypoint. Import from@apollo/clientinstead. -
#12761
db6f7c3Thanks @phryneas! - Deprecate second argument toreadFragmentandreadQuery-optimisticshould be passed as part of the object in the first argument instead.
@apollo/[email protected]
Patch Changes
- #12775
454ec78Thanks @jerelmiller! - Don't exportgqlfrom@apollo/client/reactentrypoint. Import from@apollo/clientinstead.