Skip to content

Commit

Permalink
watchFragment fixes (#11754)
Browse files Browse the repository at this point in the history
  • Loading branch information
alessbell authored Apr 4, 2024
1 parent 4cbd229 commit 80d2ba5
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 15 deletions.
6 changes: 2 additions & 4 deletions .api-reports/api-report-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
// (undocumented)
abstract watch<TData = any, TVariables = any>(watch: Cache_2.WatchOptions<TData, TVariables>): () => void;
// Warning: (ae-forgotten-export) The symbol "OperationVariables" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "WatchFragmentOptions" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "WatchFragmentResult" needs to be exported by the entry point index.d.ts
watchFragment<TData = any, TVars = OperationVariables>(options: WatchFragmentOptions<TData, TVars>): Observable<WatchFragmentResult<TData>>;
// (undocumented)
abstract write<TData = any, TVariables = any>(write: Cache_2.WriteOptions<TData, TVariables>): Reference | undefined;
Expand Down Expand Up @@ -977,7 +975,7 @@ export type TypePolicy = {
};

// @public
interface WatchFragmentOptions<TData, TVars> {
export interface WatchFragmentOptions<TData, TVars> {
// @deprecated (undocumented)
canonizeResults?: boolean;
fragment: DocumentNode | TypedDocumentNode<TData, TVars>;
Expand All @@ -988,7 +986,7 @@ interface WatchFragmentOptions<TData, TVars> {
}

// @public
type WatchFragmentResult<TData> = {
export type WatchFragmentResult<TData> = {
data: TData;
complete: true;
missing?: never;
Expand Down
6 changes: 2 additions & 4 deletions .api-reports/api-report-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
updateQuery<TData = any, TVariables = any>(options: Cache_2.UpdateQueryOptions<TData, TVariables>, update: (data: TData | null) => TData | null | void): TData | null;
// (undocumented)
abstract watch<TData = any, TVariables = any>(watch: Cache_2.WatchOptions<TData, TVariables>): () => void;
// Warning: (ae-forgotten-export) The symbol "WatchFragmentOptions" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "WatchFragmentResult" needs to be exported by the entry point index.d.ts
watchFragment<TData = any, TVars = OperationVariables>(options: WatchFragmentOptions<TData, TVars>): Observable<WatchFragmentResult<TData>>;
// (undocumented)
abstract write<TData = any, TVariables = any>(write: Cache_2.WriteOptions<TData, TVariables>): Reference | undefined;
Expand Down Expand Up @@ -2213,7 +2211,7 @@ export interface UriFunction {
}

// @public
interface WatchFragmentOptions<TData, TVars> {
export interface WatchFragmentOptions<TData, TVars> {
// @deprecated (undocumented)
canonizeResults?: boolean;
fragment: DocumentNode | TypedDocumentNode<TData, TVars>;
Expand All @@ -2224,7 +2222,7 @@ interface WatchFragmentOptions<TData, TVars> {
}

// @public
type WatchFragmentResult<TData> = {
export type WatchFragmentResult<TData> = {
data: TData;
complete: true;
missing?: never;
Expand Down
6 changes: 2 additions & 4 deletions .api-reports/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
updateQuery<TData = any, TVariables = any>(options: Cache_2.UpdateQueryOptions<TData, TVariables>, update: (data: TData | null) => TData | null | void): TData | null;
// (undocumented)
abstract watch<TData = any, TVariables = any>(watch: Cache_2.WatchOptions<TData, TVariables>): () => void;
// Warning: (ae-forgotten-export) The symbol "WatchFragmentOptions" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "WatchFragmentResult" needs to be exported by the entry point index.d.ts
watchFragment<TData = any, TVars = OperationVariables>(options: WatchFragmentOptions<TData, TVars>): Observable<WatchFragmentResult<TData>>;
// (undocumented)
abstract write<TData = any, TVariables = any>(write: Cache_2.WriteOptions<TData, TVariables>): Reference | undefined;
Expand Down Expand Up @@ -3023,7 +3021,7 @@ TVariables
};

// @public
interface WatchFragmentOptions<TData, TVars> {
export interface WatchFragmentOptions<TData, TVars> {
// @deprecated (undocumented)
canonizeResults?: boolean;
fragment: DocumentNode | TypedDocumentNode<TData, TVars>;
Expand All @@ -3034,7 +3032,7 @@ interface WatchFragmentOptions<TData, TVars> {
}

// @public
type WatchFragmentResult<TData> = {
export type WatchFragmentResult<TData> = {
data: TData;
complete: true;
missing?: never;
Expand Down
5 changes: 5 additions & 0 deletions .changeset/old-onions-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": patch
---

Export `WatchFragmentOptions` and `WatchFragmentResult` from main entrypoint and fix bug where `this` wasn't bound to the `watchFragment` method on `ApolloClient`.
4 changes: 2 additions & 2 deletions .size-limits.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"dist/apollo-client.min.cjs": 39510,
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32799
"dist/apollo-client.min.cjs": 39518,
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32809
}
6 changes: 5 additions & 1 deletion src/cache/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import "../utilities/globals/index.js";

export type { Transaction } from "./core/cache.js";
export type {
Transaction,
WatchFragmentOptions,
WatchFragmentResult,
} from "./core/cache.js";
export { ApolloCache } from "./core/cache.js";
export { Cache } from "./core/types/Cache.js";
export type { DataProxy } from "./core/types/DataProxy.js";
Expand Down
1 change: 1 addition & 0 deletions src/core/ApolloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ export class ApolloClient<TCacheShape> implements DataProxy {
this.watchQuery = this.watchQuery.bind(this);
this.query = this.query.bind(this);
this.mutate = this.mutate.bind(this);
this.watchFragment = this.watchFragment.bind(this);
this.resetStore = this.resetStore.bind(this);
this.reFetchObservableQueries = this.reFetchObservableQueries.bind(this);

Expand Down
2 changes: 2 additions & 0 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export type {
FieldMergeFunction,
FieldFunctionOptions,
PossibleTypesMap,
WatchFragmentOptions,
WatchFragmentResult,
} from "../cache/index.js";
export {
Cache,
Expand Down

0 comments on commit 80d2ba5

Please sign in to comment.