Skip to content

Commit 80d2ba5

Browse files
authored
watchFragment fixes (#11754)
1 parent 4cbd229 commit 80d2ba5

File tree

8 files changed

+21
-15
lines changed

8 files changed

+21
-15
lines changed

.api-reports/api-report-cache.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
6565
// (undocumented)
6666
abstract watch<TData = any, TVariables = any>(watch: Cache_2.WatchOptions<TData, TVariables>): () => void;
6767
// Warning: (ae-forgotten-export) The symbol "OperationVariables" needs to be exported by the entry point index.d.ts
68-
// Warning: (ae-forgotten-export) The symbol "WatchFragmentOptions" needs to be exported by the entry point index.d.ts
69-
// Warning: (ae-forgotten-export) The symbol "WatchFragmentResult" needs to be exported by the entry point index.d.ts
7068
watchFragment<TData = any, TVars = OperationVariables>(options: WatchFragmentOptions<TData, TVars>): Observable<WatchFragmentResult<TData>>;
7169
// (undocumented)
7270
abstract write<TData = any, TVariables = any>(write: Cache_2.WriteOptions<TData, TVariables>): Reference | undefined;
@@ -977,7 +975,7 @@ export type TypePolicy = {
977975
};
978976

979977
// @public
980-
interface WatchFragmentOptions<TData, TVars> {
978+
export interface WatchFragmentOptions<TData, TVars> {
981979
// @deprecated (undocumented)
982980
canonizeResults?: boolean;
983981
fragment: DocumentNode | TypedDocumentNode<TData, TVars>;
@@ -988,7 +986,7 @@ interface WatchFragmentOptions<TData, TVars> {
988986
}
989987

990988
// @public
991-
type WatchFragmentResult<TData> = {
989+
export type WatchFragmentResult<TData> = {
992990
data: TData;
993991
complete: true;
994992
missing?: never;

.api-reports/api-report-core.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
7979
updateQuery<TData = any, TVariables = any>(options: Cache_2.UpdateQueryOptions<TData, TVariables>, update: (data: TData | null) => TData | null | void): TData | null;
8080
// (undocumented)
8181
abstract watch<TData = any, TVariables = any>(watch: Cache_2.WatchOptions<TData, TVariables>): () => void;
82-
// Warning: (ae-forgotten-export) The symbol "WatchFragmentOptions" needs to be exported by the entry point index.d.ts
83-
// Warning: (ae-forgotten-export) The symbol "WatchFragmentResult" needs to be exported by the entry point index.d.ts
8482
watchFragment<TData = any, TVars = OperationVariables>(options: WatchFragmentOptions<TData, TVars>): Observable<WatchFragmentResult<TData>>;
8583
// (undocumented)
8684
abstract write<TData = any, TVariables = any>(write: Cache_2.WriteOptions<TData, TVariables>): Reference | undefined;
@@ -2213,7 +2211,7 @@ export interface UriFunction {
22132211
}
22142212

22152213
// @public
2216-
interface WatchFragmentOptions<TData, TVars> {
2214+
export interface WatchFragmentOptions<TData, TVars> {
22172215
// @deprecated (undocumented)
22182216
canonizeResults?: boolean;
22192217
fragment: DocumentNode | TypedDocumentNode<TData, TVars>;
@@ -2224,7 +2222,7 @@ interface WatchFragmentOptions<TData, TVars> {
22242222
}
22252223

22262224
// @public
2227-
type WatchFragmentResult<TData> = {
2225+
export type WatchFragmentResult<TData> = {
22282226
data: TData;
22292227
complete: true;
22302228
missing?: never;

.api-reports/api-report.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
8181
updateQuery<TData = any, TVariables = any>(options: Cache_2.UpdateQueryOptions<TData, TVariables>, update: (data: TData | null) => TData | null | void): TData | null;
8282
// (undocumented)
8383
abstract watch<TData = any, TVariables = any>(watch: Cache_2.WatchOptions<TData, TVariables>): () => void;
84-
// Warning: (ae-forgotten-export) The symbol "WatchFragmentOptions" needs to be exported by the entry point index.d.ts
85-
// Warning: (ae-forgotten-export) The symbol "WatchFragmentResult" needs to be exported by the entry point index.d.ts
8684
watchFragment<TData = any, TVars = OperationVariables>(options: WatchFragmentOptions<TData, TVars>): Observable<WatchFragmentResult<TData>>;
8785
// (undocumented)
8886
abstract write<TData = any, TVariables = any>(write: Cache_2.WriteOptions<TData, TVariables>): Reference | undefined;
@@ -3023,7 +3021,7 @@ TVariables
30233021
};
30243022

30253023
// @public
3026-
interface WatchFragmentOptions<TData, TVars> {
3024+
export interface WatchFragmentOptions<TData, TVars> {
30273025
// @deprecated (undocumented)
30283026
canonizeResults?: boolean;
30293027
fragment: DocumentNode | TypedDocumentNode<TData, TVars>;
@@ -3034,7 +3032,7 @@ interface WatchFragmentOptions<TData, TVars> {
30343032
}
30353033

30363034
// @public
3037-
type WatchFragmentResult<TData> = {
3035+
export type WatchFragmentResult<TData> = {
30383036
data: TData;
30393037
complete: true;
30403038
missing?: never;

.changeset/old-onions-sleep.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@apollo/client": patch
3+
---
4+
5+
Export `WatchFragmentOptions` and `WatchFragmentResult` from main entrypoint and fix bug where `this` wasn't bound to the `watchFragment` method on `ApolloClient`.

.size-limits.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"dist/apollo-client.min.cjs": 39510,
3-
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32799
2+
"dist/apollo-client.min.cjs": 39518,
3+
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32809
44
}

src/cache/index.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import "../utilities/globals/index.js";
22

3-
export type { Transaction } from "./core/cache.js";
3+
export type {
4+
Transaction,
5+
WatchFragmentOptions,
6+
WatchFragmentResult,
7+
} from "./core/cache.js";
48
export { ApolloCache } from "./core/cache.js";
59
export { Cache } from "./core/types/Cache.js";
610
export type { DataProxy } from "./core/types/DataProxy.js";

src/core/ApolloClient.ts

+1
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ export class ApolloClient<TCacheShape> implements DataProxy {
239239
this.watchQuery = this.watchQuery.bind(this);
240240
this.query = this.query.bind(this);
241241
this.mutate = this.mutate.bind(this);
242+
this.watchFragment = this.watchFragment.bind(this);
242243
this.resetStore = this.resetStore.bind(this);
243244
this.reFetchObservableQueries = this.reFetchObservableQueries.bind(this);
244245

src/core/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export type {
4040
FieldMergeFunction,
4141
FieldFunctionOptions,
4242
PossibleTypesMap,
43+
WatchFragmentOptions,
44+
WatchFragmentResult,
4345
} from "../cache/index.js";
4446
export {
4547
Cache,

0 commit comments

Comments
 (0)