Caution
Before upgrading apollo-angular
to v12, be sure to read all the breaking changes from @apollo/client
v4 that also applies to apollo-angular
.
Major Changes
-
#2372
44ed9a5
Thanks @jerelmiller! - Namespaced typesBefore:
import type { MutationOptionsAlone, QueryOptionsAlone, SubscriptionOptionsAlone, WatchQueryOptions, WatchQueryOptionsAlone, } from 'apollo-angular'; import type { BatchOptions, Options } from 'apollo-angular/http'; type AllTypes = | Options | BatchOptions | MutationOptionsAlone | QueryOptionsAlone | SubscriptionOptionsAlone | WatchQueryOptions | WatchQueryOptionsAlone;
After:
import type { Apollo, Mutation, Query, Subscription } from 'apollo-angular'; import type { HttpBatchLink, HttpLink } from 'apollo-angular/http'; type AllTypes = | HttpLink.Options | HttpBatchLink.Options | Mutation.MutateOptions | Query.FetchOptions | Subscription.SubscribeOptions | Apollo.WatchQueryOptions | Query.WatchOptions;
-
#2372
bdc93df
Thanks @jerelmiller! -httpHeaders
is a classMigrate your code like so:
- const link = httpHeaders(); + const link = new HttpHeadersLink();
-
#2372
8c0b7f0
Thanks @jerelmiller! - MoveuseZone
option into subscription
options- const obs = apollo.subscribe(options, { useZone: false }); + const obs = apollo.subscribe({ ...options, useZone: false });
-
#2372
b9c62a5
Thanks @jerelmiller! - Combined parameters ofQuery
,
Mutation
andSubscription
classes generated via codegenMigrate your code like so:
class MyComponent { myQuery = inject(MyQuery); myMutation = inject(MyMutation); mySubscription = inject(MySubscription); constructor() { - myQuery.watch({ myVariable: 'foo' }, { fetchPolicy: 'cache-and-network' }); + myQuery.watch({ variables: { myVariable: 'foo' }, fetchPolicy: 'cache-and-network' }) - myMutation.mutate({ myVariable: 'foo' }, { errorPolicy: 'ignore' }); + myMutation.mutate({ variables: { myVariable: 'foo' }, errorPolicy: 'ignore' }); - mySubscription.subscribe({ myVariable: 'foo' }, { fetchPolicy: 'network-only' }); + mySubscription.subscribe({ variables: { myVariable: 'foo' }, fetchPolicy: 'network-only' }); } }
Minor Changes
-
#2379
7e4a609
Thanks @PowerKiKi! - NewonlyComplete()
helper to filter only
complete resultsIf you use this, you should probably combine it with
notifyOnNetworkStatusChange
.
This tells@apollo/client
to not emit the firstpartial
result, soapollo-angular
does not
need to filter it out. The overall behavior is identical, but it saves some CPU cycles.So something like this:
apollo .watchQuery({ query: myQuery, notifyOnNetworkStatusChange: false, // Adding this will save CPU cycles }) .valueChanges.pipe(onlyComplete()) .subscribe(result => { // Do something with complete result });
Patch Changes
-
#2355
226a963
Thanks @PowerKiKi! - dependencies updates:- Updated dependency
@apollo/client@^4.0.1
↗︎ (from
^3.13.1
, inpeerDependencies
) - Updated dependency
rxjs@^7.3.0
↗︎ (from
^6.0.0 || ^7.0.0
, inpeerDependencies
)
- Updated dependency
-
#2373
e65bcce
Thanks @PowerKiKi! - Drop support for node 18 -
#2366
bdff9d9
Thanks @PowerKiKi! - Drop ESM2022 in favor of FESM2022 -
#2368
0f10355
Thanks @PowerKiKi! - New repository owners@kamilkisiela, the creator of this library, has found new
interests and is not able to contribute like in the past. He gracefully transferred ownership of
the repository to me. I have been maintaining this library since 2022, and will continue doing so
in the foreseeable future.For the package consumers, pretty much nothing will change. The package name, the code, the
relation with The Guild, and the maintenance style will all
remain the same. The only difference is the new repository URL:
https://github.com/the-guild-org/apollo-angular.