Skip to content

Commit 5ed2cfd

Browse files
alessbellphryneas
andauthored
Make private fields protected in QueryManager (#11013)
* chore: create PR for snapshot test * chore: make QueryManager private fields protected * chore: add changeset * Revert "chore: make QueryManager private fields protected" This reverts commit e0639d3. * chore: add code comments * chore: update changeset text --------- Co-authored-by: Lenz Weber-Tronic <[email protected]>
1 parent 6a4da90 commit 5ed2cfd

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

.changeset/dry-tools-chew.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@apollo/client': patch
3+
---
4+
5+
Make private fields `inFlightLinkObservables` and `fetchCancelFns` protected in QueryManager in order to make types available in [`@apollo/experimental-nextjs-app-support`](https://www.npmjs.com/package/@apollo/experimental-nextjs-app-support) package when extending the `ApolloClient` class.

src/core/QueryManager.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ export class QueryManager<TStore> {
118118

119119
// Maps from queryId strings to Promise rejection functions for
120120
// currently active queries and fetches.
121-
private fetchCancelFns = new Map<string, (error: any) => any>();
121+
// Use protected instead of private field so
122+
// @apollo/experimental-nextjs-app-support can access type info.
123+
protected fetchCancelFns = new Map<string, (error: any) => any>();
122124

123125
constructor({
124126
cache,
@@ -144,7 +146,7 @@ export class QueryManager<TStore> {
144146
assumeImmutableResults?: boolean;
145147
}) {
146148
const defaultDocumentTransform = new DocumentTransform(
147-
(document) => this.cache.transformDocument(document),
149+
(document) => this.cache.transformDocument(document),
148150
// Allow the apollo cache to manage its own transform caches
149151
{ cache: false }
150152
);
@@ -161,8 +163,8 @@ export class QueryManager<TStore> {
161163
? defaultDocumentTransform
162164
.concat(documentTransform)
163165
// The custom document transform may add new fragment spreads or new
164-
// field selections, so we want to give the cache a chance to run
165-
// again. For example, the InMemoryCache adds __typename to field
166+
// field selections, so we want to give the cache a chance to run
167+
// again. For example, the InMemoryCache adds __typename to field
166168
// selections and fragments from the fragment registry.
167169
.concat(defaultDocumentTransform)
168170
: defaultDocumentTransform
@@ -695,7 +697,7 @@ export class QueryManager<TStore> {
695697
const query = this.transform(options.query);
696698

697699
// assign variable default values if supplied
698-
// NOTE: We don't modify options.query here with the transformed query to
700+
// NOTE: We don't modify options.query here with the transformed query to
699701
// ensure observable.options.query is set to the raw untransformed query.
700702
options = {
701703
...options,
@@ -719,7 +721,7 @@ export class QueryManager<TStore> {
719721

720722
this.queries.set(observable.queryId, queryInfo);
721723

722-
// We give queryInfo the transformed query to ensure the first cache diff
724+
// We give queryInfo the transformed query to ensure the first cache diff
723725
// uses the transformed query instead of the raw query
724726
queryInfo.init({
725727
document: query,
@@ -1027,7 +1029,9 @@ export class QueryManager<TStore> {
10271029
return this.localState;
10281030
}
10291031

1030-
private inFlightLinkObservables = new Map<
1032+
// Use protected instead of private field so
1033+
// @apollo/experimental-nextjs-app-support can access type info.
1034+
protected inFlightLinkObservables = new Map<
10311035
string,
10321036
Map<string, Observable<FetchResult>>
10331037
>();

0 commit comments

Comments
 (0)