diff --git a/.api-reports/api-report-cache.md b/.api-reports/api-report-cache.md index 7eed64d3052..0bf245fdeb9 100644 --- a/.api-reports/api-report-cache.md +++ b/.api-reports/api-report-cache.md @@ -8,9 +8,10 @@ import type { DocumentNode } from 'graphql'; import type { FieldNode } from 'graphql'; import type { FragmentDefinitionNode } from 'graphql'; import type { InlineFragmentNode } from 'graphql'; +import { Observable } from 'zen-observable-ts'; import type { SelectionSetNode } from 'graphql'; import { Trie } from '@wry/trie'; -import type { TypedDocumentNode } from '@graphql-typed-document-node/core'; +import { TypedDocumentNode } from '@graphql-typed-document-node/core'; // Warning: (ae-forgotten-export) The symbol "StoreObjectValueMaybeReference" needs to be exported by the entry point index.d.ts // @@ -63,6 +64,10 @@ export abstract class ApolloCache implements DataProxy { updateQuery(options: Cache_2.UpdateQueryOptions, update: (data: TData | null) => TData | null | void): TData | null; // (undocumented) abstract watch(watch: Cache_2.WatchOptions): () => 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(options: WatchFragmentOptions): Observable>; // (undocumented) abstract write(write: Cache_2.WriteOptions): Reference | undefined; // (undocumented) @@ -274,6 +279,40 @@ export interface DataProxy { writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; } +// Warning: (ae-forgotten-export) The symbol "DeepPartialPrimitive" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialMap" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlyMap" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialSet" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlySet" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialObject" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartial = T extends DeepPartialPrimitive ? T : T extends Map ? DeepPartialMap : T extends ReadonlyMap ? DeepPartialReadonlyMap : T extends Set ? DeepPartialSet : T extends ReadonlySet ? DeepPartialReadonlySet : T extends (...args: any[]) => unknown ? T | undefined : T extends object ? T extends (ReadonlyArray) ? TItem[] extends (T) ? readonly TItem[] extends T ? ReadonlyArray> : Array> : DeepPartialObject : DeepPartialObject : unknown; + +// Warning: (ae-forgotten-export) The symbol "DeepPartial" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartialMap = {} & Map, DeepPartial>; + +// @public (undocumented) +type DeepPartialObject = { + [K in keyof T]?: DeepPartial; +}; + +// Warning: (ae-forgotten-export) The symbol "Primitive" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartialPrimitive = Primitive | Date | RegExp; + +// @public (undocumented) +type DeepPartialReadonlyMap = {} & ReadonlyMap, DeepPartial>; + +// @public (undocumented) +type DeepPartialReadonlySet = {} & ReadonlySet>; + +// @public (undocumented) +type DeepPartialSet = {} & Set>; + // Warning: (ae-forgotten-export) The symbol "KeyFieldsContext" needs to be exported by the entry point index.d.ts // // @public (undocumented) @@ -533,8 +572,6 @@ export class InMemoryCache extends ApolloCache { protected broadcastWatches(options?: BroadcastOptions): void; // (undocumented) protected config: InMemoryCacheConfig; - // Warning: (ae-forgotten-export) The symbol "OperationVariables" needs to be exported by the entry point index.d.ts - // // (undocumented) diff(options: Cache_2.DiffOptions): Cache_2.DiffResult; // (undocumented) @@ -824,6 +861,9 @@ export type PossibleTypesMap = { [supertype: string]: string[]; }; +// @public (undocumented) +type Primitive = null | undefined | string | number | boolean | symbol | bigint; + // @public (undocumented) type ReactiveListener = (value: T) => any; @@ -936,6 +976,28 @@ export type TypePolicy = { }; }; +// @public +interface WatchFragmentOptions { + // @deprecated (undocumented) + canonizeResults?: boolean; + fragment: DocumentNode | TypedDocumentNode; + fragmentName?: string; + from: StoreObject | Reference | string; + optimistic?: boolean; + variables?: TVars; +} + +// @public +type WatchFragmentResult = { + data: TData; + complete: true; + missing?: never; +} | { + data: DeepPartial; + complete: false; + missing: MissingTree; +}; + // @public (undocumented) interface WriteContext extends ReadMergeModifyContext { // (undocumented) diff --git a/.api-reports/api-report-core.md b/.api-reports/api-report-core.md index 1ebf61607a3..c9be0d52fb6 100644 --- a/.api-reports/api-report-core.md +++ b/.api-reports/api-report-core.md @@ -79,6 +79,9 @@ export abstract class ApolloCache implements DataProxy { updateQuery(options: Cache_2.UpdateQueryOptions, update: (data: TData | null) => TData | null | void): TData | null; // (undocumented) abstract watch(watch: Cache_2.WatchOptions): () => 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(options: WatchFragmentOptions): Observable>; // (undocumented) abstract write(write: Cache_2.WriteOptions): Reference | undefined; // (undocumented) @@ -87,8 +90,6 @@ export abstract class ApolloCache implements DataProxy { writeQuery({ id, data, ...options }: Cache_2.WriteQueryOptions): Reference | undefined; } -// Warning: (ae-unresolved-link) The @link reference could not be resolved: This type of declaration is not supported yet by the resolver -// // @public export class ApolloClient implements DataProxy { // (undocumented) @@ -130,12 +131,12 @@ export class ApolloClient implements DataProxy { setLocalStateFragmentMatcher(fragmentMatcher: FragmentMatcher): void; setResolvers(resolvers: Resolvers | Resolvers[]): void; stop(): void; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: This type of declaration is not supported yet by the resolver subscribe(options: SubscriptionOptions): Observable>; // (undocumented) readonly typeDefs: ApolloClientOptions["typeDefs"]; // (undocumented) version: string; + watchFragment(options: WatchFragmentOptions): Observable>; watchQuery(options: WatchQueryOptions): ObservableQuery; writeFragment(options: DataProxy.WriteFragmentOptions): Reference | undefined; writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; @@ -523,6 +524,40 @@ export interface DataProxy { writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; } +// Warning: (ae-forgotten-export) The symbol "DeepPartialPrimitive" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialMap" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlyMap" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialSet" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlySet" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialObject" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartial = T extends DeepPartialPrimitive ? T : T extends Map ? DeepPartialMap : T extends ReadonlyMap ? DeepPartialReadonlyMap : T extends Set ? DeepPartialSet : T extends ReadonlySet ? DeepPartialReadonlySet : T extends (...args: any[]) => unknown ? T | undefined : T extends object ? T extends (ReadonlyArray) ? TItem[] extends (T) ? readonly TItem[] extends T ? ReadonlyArray> : Array> : DeepPartialObject : DeepPartialObject : unknown; + +// Warning: (ae-forgotten-export) The symbol "DeepPartial" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartialMap = {} & Map, DeepPartial>; + +// @public (undocumented) +type DeepPartialObject = { + [K in keyof T]?: DeepPartial; +}; + +// Warning: (ae-forgotten-export) The symbol "Primitive" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartialPrimitive = Primitive | Date | RegExp; + +// @public (undocumented) +type DeepPartialReadonlyMap = {} & ReadonlyMap, DeepPartial>; + +// @public (undocumented) +type DeepPartialReadonlySet = {} & ReadonlySet>; + +// @public (undocumented) +type DeepPartialSet = {} & Set>; + // @public (undocumented) export interface DefaultContext extends Record { } @@ -1636,6 +1671,9 @@ export type PossibleTypesMap = { [supertype: string]: string[]; }; +// @public (undocumented) +type Primitive = null | undefined | string | number | boolean | symbol | bigint; + // @public (undocumented) const print_2: ((ast: ASTNode) => string) & { reset(): void; @@ -2174,6 +2212,28 @@ export interface UriFunction { (operation: Operation): string; } +// @public +interface WatchFragmentOptions { + // @deprecated (undocumented) + canonizeResults?: boolean; + fragment: DocumentNode | TypedDocumentNode; + fragmentName?: string; + from: StoreObject | Reference | string; + optimistic?: boolean; + variables?: TVars; +} + +// @public +type WatchFragmentResult = { + data: TData; + complete: true; + missing?: never; +} | { + data: DeepPartial; + complete: false; + missing: MissingTree; +}; + // @public (undocumented) export type WatchQueryFetchPolicy = FetchPolicy | "cache-and-network"; diff --git a/.api-reports/api-report-react.md b/.api-reports/api-report-react.md index 0cdf3ce93bc..6b291639724 100644 --- a/.api-reports/api-report-react.md +++ b/.api-reports/api-report-react.md @@ -80,6 +80,10 @@ abstract class ApolloCache implements DataProxy { updateQuery(options: Cache_2.UpdateQueryOptions, update: (data: TData | null) => TData | null | void): TData | null; // (undocumented) abstract watch(watch: Cache_2.WatchOptions): () => 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(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "Reference" needs to be exported by the entry point index.d.ts // // (undocumented) @@ -90,14 +94,10 @@ abstract class ApolloCache implements DataProxy { writeQuery({ id, data, ...options }: Cache_2.WriteQueryOptions): Reference | undefined; } -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" -// // @public class ApolloClient implements DataProxy { // (undocumented) __actionHookForDevTools(cb: () => any): void; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloClient" constructor(options: ApolloClientOptions); // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // @@ -135,7 +135,6 @@ class ApolloClient implements DataProxy { onResetStore(cb: () => Promise): () => void; // Warning: (ae-forgotten-export) The symbol "QueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ApolloQueryResult" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "QueryOptions" query(options: QueryOptions): Promise>; // (undocumented) queryDeduplication: boolean; @@ -153,7 +152,6 @@ class ApolloClient implements DataProxy { setResolvers(resolvers: Resolvers | Resolvers[]): void; stop(): void; // Warning: (ae-forgotten-export) The symbol "SubscriptionOptions" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" subscribe(options: SubscriptionOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "ApolloClientOptions" needs to be exported by the entry point index.d.ts // @@ -161,11 +159,9 @@ class ApolloClient implements DataProxy { readonly typeDefs: ApolloClientOptions["typeDefs"]; // (undocumented) version: string; - // Warning: (ae-forgotten-export) The symbol "OperationVariables" needs to be exported by the entry point index.d.ts + watchFragment(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "WatchQueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ObservableQuery" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" watchQuery(options: WatchQueryOptions): ObservableQuery; writeFragment(options: DataProxy.WriteFragmentOptions): Reference | undefined; writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; @@ -186,7 +182,6 @@ interface ApolloClientOptions { // (undocumented) fragmentMatcher?: FragmentMatcher; headers?: Record; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" link?: ApolloLink; name?: string; queryDeduplication?: boolean; @@ -2372,6 +2367,28 @@ TVariables variables: TVariables; }; +// @public +interface WatchFragmentOptions { + // @deprecated (undocumented) + canonizeResults?: boolean; + fragment: DocumentNode | TypedDocumentNode; + fragmentName?: string; + from: StoreObject | Reference | string; + optimistic?: boolean; + variables?: TVars; +} + +// @public +type WatchFragmentResult = { + data: TData; + complete: true; + missing?: never; +} | { + data: DeepPartial; + complete: false; + missing: MissingTree; +}; + // @public (undocumented) type WatchQueryFetchPolicy = FetchPolicy | "cache-and-network"; diff --git a/.api-reports/api-report-react_components.md b/.api-reports/api-report-react_components.md index a4e212edb9f..e209c316d27 100644 --- a/.api-reports/api-report-react_components.md +++ b/.api-reports/api-report-react_components.md @@ -80,6 +80,10 @@ abstract class ApolloCache implements DataProxy { updateQuery(options: Cache_2.UpdateQueryOptions, update: (data: TData | null) => TData | null | void): TData | null; // (undocumented) abstract watch(watch: Cache_2.WatchOptions): () => 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(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "Reference" needs to be exported by the entry point index.d.ts // // (undocumented) @@ -90,14 +94,10 @@ abstract class ApolloCache implements DataProxy { writeQuery({ id, data, ...options }: Cache_2.WriteQueryOptions): Reference | undefined; } -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" -// // @public class ApolloClient implements DataProxy { // (undocumented) __actionHookForDevTools(cb: () => any): void; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloClient" constructor(options: ApolloClientOptions); // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // @@ -136,7 +136,6 @@ class ApolloClient implements DataProxy { onResetStore(cb: () => Promise): () => void; // Warning: (ae-forgotten-export) The symbol "QueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ApolloQueryResult" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "QueryOptions" query(options: QueryOptions): Promise>; // (undocumented) queryDeduplication: boolean; @@ -154,7 +153,6 @@ class ApolloClient implements DataProxy { setResolvers(resolvers: Resolvers | Resolvers[]): void; stop(): void; // Warning: (ae-forgotten-export) The symbol "SubscriptionOptions" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" subscribe(options: SubscriptionOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "ApolloClientOptions" needs to be exported by the entry point index.d.ts // @@ -162,11 +160,9 @@ class ApolloClient implements DataProxy { readonly typeDefs: ApolloClientOptions["typeDefs"]; // (undocumented) version: string; - // Warning: (ae-forgotten-export) The symbol "OperationVariables" needs to be exported by the entry point index.d.ts + watchFragment(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "WatchQueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ObservableQuery" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" watchQuery(options: WatchQueryOptions): ObservableQuery; writeFragment(options: DataProxy.WriteFragmentOptions): Reference | undefined; writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; @@ -187,7 +183,6 @@ interface ApolloClientOptions { // (undocumented) fragmentMatcher?: FragmentMatcher; headers?: Record; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" link?: ApolloLink; name?: string; queryDeduplication?: boolean; @@ -565,6 +560,40 @@ interface DataProxy { writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; } +// Warning: (ae-forgotten-export) The symbol "DeepPartialPrimitive" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialMap" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlyMap" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialSet" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlySet" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialObject" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartial = T extends DeepPartialPrimitive ? T : T extends Map ? DeepPartialMap : T extends ReadonlyMap ? DeepPartialReadonlyMap : T extends Set ? DeepPartialSet : T extends ReadonlySet ? DeepPartialReadonlySet : T extends (...args: any[]) => unknown ? T | undefined : T extends object ? T extends (ReadonlyArray) ? TItem[] extends (T) ? readonly TItem[] extends T ? ReadonlyArray> : Array> : DeepPartialObject : DeepPartialObject : unknown; + +// Warning: (ae-forgotten-export) The symbol "DeepPartial" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartialMap = {} & Map, DeepPartial>; + +// @public (undocumented) +type DeepPartialObject = { + [K in keyof T]?: DeepPartial; +}; + +// Warning: (ae-forgotten-export) The symbol "Primitive" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartialPrimitive = Primitive | Date | RegExp; + +// @public (undocumented) +type DeepPartialReadonlyMap = {} & ReadonlyMap, DeepPartial>; + +// @public (undocumented) +type DeepPartialReadonlySet = {} & ReadonlySet>; + +// @public (undocumented) +type DeepPartialSet = {} & Set>; + // @public (undocumented) interface DefaultContext extends Record { } @@ -1203,6 +1232,9 @@ type OperationVariables = Record; // @public (undocumented) type Path = ReadonlyArray; +// @public (undocumented) +type Primitive = null | undefined | string | number | boolean | symbol | bigint; + // @public @deprecated (undocumented) export function Query(props: QueryComponentOptions): ReactTypes.JSX.Element | null; @@ -1712,6 +1744,28 @@ interface UriFunction { (operation: Operation): string; } +// @public +interface WatchFragmentOptions { + // @deprecated (undocumented) + canonizeResults?: boolean; + fragment: DocumentNode | TypedDocumentNode; + fragmentName?: string; + from: StoreObject | Reference | string; + optimistic?: boolean; + variables?: TVars; +} + +// @public +type WatchFragmentResult = { + data: TData; + complete: true; + missing?: never; +} | { + data: DeepPartial; + complete: false; + missing: MissingTree; +}; + // @public (undocumented) type WatchQueryFetchPolicy = FetchPolicy | "cache-and-network"; diff --git a/.api-reports/api-report-react_context.md b/.api-reports/api-report-react_context.md index 3ec73691a66..00227f7c365 100644 --- a/.api-reports/api-report-react_context.md +++ b/.api-reports/api-report-react_context.md @@ -79,6 +79,10 @@ abstract class ApolloCache implements DataProxy { updateQuery(options: Cache_2.UpdateQueryOptions, update: (data: TData | null) => TData | null | void): TData | null; // (undocumented) abstract watch(watch: Cache_2.WatchOptions): () => 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(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "Reference" needs to be exported by the entry point index.d.ts // // (undocumented) @@ -89,14 +93,10 @@ abstract class ApolloCache implements DataProxy { writeQuery({ id, data, ...options }: Cache_2.WriteQueryOptions): Reference | undefined; } -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" -// // @public class ApolloClient implements DataProxy { // (undocumented) __actionHookForDevTools(cb: () => any): void; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloClient" constructor(options: ApolloClientOptions); // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // @@ -135,7 +135,6 @@ class ApolloClient implements DataProxy { onResetStore(cb: () => Promise): () => void; // Warning: (ae-forgotten-export) The symbol "QueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ApolloQueryResult" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "QueryOptions" query(options: QueryOptions): Promise>; // (undocumented) queryDeduplication: boolean; @@ -153,7 +152,6 @@ class ApolloClient implements DataProxy { setResolvers(resolvers: Resolvers | Resolvers[]): void; stop(): void; // Warning: (ae-forgotten-export) The symbol "SubscriptionOptions" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" subscribe(options: SubscriptionOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "ApolloClientOptions" needs to be exported by the entry point index.d.ts // @@ -161,11 +159,9 @@ class ApolloClient implements DataProxy { readonly typeDefs: ApolloClientOptions["typeDefs"]; // (undocumented) version: string; - // Warning: (ae-forgotten-export) The symbol "OperationVariables" needs to be exported by the entry point index.d.ts + watchFragment(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "WatchQueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ObservableQuery" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" watchQuery(options: WatchQueryOptions): ObservableQuery; writeFragment(options: DataProxy.WriteFragmentOptions): Reference | undefined; writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; @@ -186,7 +182,6 @@ interface ApolloClientOptions { // (undocumented) fragmentMatcher?: FragmentMatcher; headers?: Record; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" link?: ApolloLink; name?: string; queryDeduplication?: boolean; @@ -563,6 +558,40 @@ interface DataProxy { writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; } +// Warning: (ae-forgotten-export) The symbol "DeepPartialPrimitive" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialMap" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlyMap" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialSet" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlySet" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialObject" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartial = T extends DeepPartialPrimitive ? T : T extends Map ? DeepPartialMap : T extends ReadonlyMap ? DeepPartialReadonlyMap : T extends Set ? DeepPartialSet : T extends ReadonlySet ? DeepPartialReadonlySet : T extends (...args: any[]) => unknown ? T | undefined : T extends object ? T extends (ReadonlyArray) ? TItem[] extends (T) ? readonly TItem[] extends T ? ReadonlyArray> : Array> : DeepPartialObject : DeepPartialObject : unknown; + +// Warning: (ae-forgotten-export) The symbol "DeepPartial" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartialMap = {} & Map, DeepPartial>; + +// @public (undocumented) +type DeepPartialObject = { + [K in keyof T]?: DeepPartial; +}; + +// Warning: (ae-forgotten-export) The symbol "Primitive" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartialPrimitive = Primitive | Date | RegExp; + +// @public (undocumented) +type DeepPartialReadonlyMap = {} & ReadonlyMap, DeepPartial>; + +// @public (undocumented) +type DeepPartialReadonlySet = {} & ReadonlySet>; + +// @public (undocumented) +type DeepPartialSet = {} & Set>; + // @public (undocumented) interface DefaultContext extends Record { } @@ -1142,6 +1171,9 @@ type OperationVariables = Record; // @public (undocumented) type Path = ReadonlyArray; +// @public (undocumented) +type Primitive = null | undefined | string | number | boolean | symbol | bigint; + // @public (undocumented) interface QueryData { // (undocumented) @@ -1635,6 +1667,28 @@ interface UriFunction { (operation: Operation): string; } +// @public +interface WatchFragmentOptions { + // @deprecated (undocumented) + canonizeResults?: boolean; + fragment: DocumentNode | TypedDocumentNode; + fragmentName?: string; + from: StoreObject | Reference | string; + optimistic?: boolean; + variables?: TVars; +} + +// @public +type WatchFragmentResult = { + data: TData; + complete: true; + missing?: never; +} | { + data: DeepPartial; + complete: false; + missing: MissingTree; +}; + // @public (undocumented) type WatchQueryFetchPolicy = FetchPolicy | "cache-and-network"; diff --git a/.api-reports/api-report-react_hoc.md b/.api-reports/api-report-react_hoc.md index 107a19b3bbd..48734526078 100644 --- a/.api-reports/api-report-react_hoc.md +++ b/.api-reports/api-report-react_hoc.md @@ -79,6 +79,10 @@ abstract class ApolloCache implements DataProxy { updateQuery(options: Cache_2.UpdateQueryOptions, update: (data: TData | null) => TData | null | void): TData | null; // (undocumented) abstract watch(watch: Cache_2.WatchOptions): () => 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(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "Reference" needs to be exported by the entry point index.d.ts // // (undocumented) @@ -89,14 +93,10 @@ abstract class ApolloCache implements DataProxy { writeQuery({ id, data, ...options }: Cache_2.WriteQueryOptions): Reference | undefined; } -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" -// // @public class ApolloClient implements DataProxy { // (undocumented) __actionHookForDevTools(cb: () => any): void; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloClient" constructor(options: ApolloClientOptions); // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // @@ -135,7 +135,6 @@ class ApolloClient implements DataProxy { onResetStore(cb: () => Promise): () => void; // Warning: (ae-forgotten-export) The symbol "QueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ApolloQueryResult" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "QueryOptions" query(options: QueryOptions): Promise>; // (undocumented) queryDeduplication: boolean; @@ -153,7 +152,6 @@ class ApolloClient implements DataProxy { setResolvers(resolvers: Resolvers | Resolvers[]): void; stop(): void; // Warning: (ae-forgotten-export) The symbol "SubscriptionOptions" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" subscribe(options: SubscriptionOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "ApolloClientOptions" needs to be exported by the entry point index.d.ts // @@ -161,11 +159,9 @@ class ApolloClient implements DataProxy { readonly typeDefs: ApolloClientOptions["typeDefs"]; // (undocumented) version: string; - // Warning: (ae-forgotten-export) The symbol "OperationVariables" needs to be exported by the entry point index.d.ts + watchFragment(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "WatchQueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ObservableQuery" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" watchQuery(options: WatchQueryOptions): ObservableQuery; writeFragment(options: DataProxy.WriteFragmentOptions): Reference | undefined; writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; @@ -186,7 +182,6 @@ interface ApolloClientOptions { // (undocumented) fragmentMatcher?: FragmentMatcher; headers?: Record; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" link?: ApolloLink; name?: string; queryDeduplication?: boolean; @@ -561,6 +556,40 @@ interface DataProxy { // @public (undocumented) export type DataValue = QueryControls & Partial; +// Warning: (ae-forgotten-export) The symbol "DeepPartialPrimitive" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialMap" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlyMap" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialSet" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlySet" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialObject" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartial = T extends DeepPartialPrimitive ? T : T extends Map ? DeepPartialMap : T extends ReadonlyMap ? DeepPartialReadonlyMap : T extends Set ? DeepPartialSet : T extends ReadonlySet ? DeepPartialReadonlySet : T extends (...args: any[]) => unknown ? T | undefined : T extends object ? T extends (ReadonlyArray) ? TItem[] extends (T) ? readonly TItem[] extends T ? ReadonlyArray> : Array> : DeepPartialObject : DeepPartialObject : unknown; + +// Warning: (ae-forgotten-export) The symbol "DeepPartial" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartialMap = {} & Map, DeepPartial>; + +// @public (undocumented) +type DeepPartialObject = { + [K in keyof T]?: DeepPartial; +}; + +// Warning: (ae-forgotten-export) The symbol "Primitive" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartialPrimitive = Primitive | Date | RegExp; + +// @public (undocumented) +type DeepPartialReadonlyMap = {} & ReadonlyMap, DeepPartial>; + +// @public (undocumented) +type DeepPartialReadonlySet = {} & ReadonlySet>; + +// @public (undocumented) +type DeepPartialSet = {} & Set>; + // @public (undocumented) interface DefaultContext extends Record { } @@ -1189,6 +1218,9 @@ export interface OptionProps; +// @public (undocumented) +type Primitive = null | undefined | string | number | boolean | symbol | bigint; + // @public (undocumented) export interface QueryControls { // (undocumented) @@ -1647,6 +1679,28 @@ interface UriFunction { (operation: Operation): string; } +// @public +interface WatchFragmentOptions { + // @deprecated (undocumented) + canonizeResults?: boolean; + fragment: DocumentNode | TypedDocumentNode; + fragmentName?: string; + from: StoreObject | Reference | string; + optimistic?: boolean; + variables?: TVars; +} + +// @public +type WatchFragmentResult = { + data: TData; + complete: true; + missing?: never; +} | { + data: DeepPartial; + complete: false; + missing: MissingTree; +}; + // @public (undocumented) type WatchQueryFetchPolicy = FetchPolicy | "cache-and-network"; diff --git a/.api-reports/api-report-react_hooks.md b/.api-reports/api-report-react_hooks.md index 4abfa6b4bd0..8297aa40a2d 100644 --- a/.api-reports/api-report-react_hooks.md +++ b/.api-reports/api-report-react_hooks.md @@ -78,6 +78,10 @@ abstract class ApolloCache implements DataProxy { updateQuery(options: Cache_2.UpdateQueryOptions, update: (data: TData | null) => TData | null | void): TData | null; // (undocumented) abstract watch(watch: Cache_2.WatchOptions): () => 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(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "Reference" needs to be exported by the entry point index.d.ts // // (undocumented) @@ -88,14 +92,10 @@ abstract class ApolloCache implements DataProxy { writeQuery({ id, data, ...options }: Cache_2.WriteQueryOptions): Reference | undefined; } -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" -// // @public class ApolloClient implements DataProxy { // (undocumented) __actionHookForDevTools(cb: () => any): void; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloClient" constructor(options: ApolloClientOptions); // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // @@ -134,7 +134,6 @@ class ApolloClient implements DataProxy { onResetStore(cb: () => Promise): () => void; // Warning: (ae-forgotten-export) The symbol "QueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ApolloQueryResult" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "QueryOptions" query(options: QueryOptions): Promise>; // (undocumented) queryDeduplication: boolean; @@ -152,7 +151,6 @@ class ApolloClient implements DataProxy { setResolvers(resolvers: Resolvers | Resolvers[]): void; stop(): void; // Warning: (ae-forgotten-export) The symbol "SubscriptionOptions" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" subscribe(options: SubscriptionOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "ApolloClientOptions" needs to be exported by the entry point index.d.ts // @@ -160,11 +158,9 @@ class ApolloClient implements DataProxy { readonly typeDefs: ApolloClientOptions["typeDefs"]; // (undocumented) version: string; - // Warning: (ae-forgotten-export) The symbol "OperationVariables" needs to be exported by the entry point index.d.ts + watchFragment(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "WatchQueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ObservableQuery" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" watchQuery(options: WatchQueryOptions): ObservableQuery; writeFragment(options: DataProxy.WriteFragmentOptions): Reference | undefined; writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; @@ -185,7 +181,6 @@ interface ApolloClientOptions { // (undocumented) fragmentMatcher?: FragmentMatcher; headers?: Record; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" link?: ApolloLink; name?: string; queryDeduplication?: boolean; @@ -2208,6 +2203,28 @@ export interface UseSuspenseQueryResult; } +// @public +interface WatchFragmentOptions { + // @deprecated (undocumented) + canonizeResults?: boolean; + fragment: DocumentNode | TypedDocumentNode; + fragmentName?: string; + from: StoreObject | Reference | string; + optimistic?: boolean; + variables?: TVars; +} + +// @public +type WatchFragmentResult = { + data: TData; + complete: true; + missing?: never; +} | { + data: DeepPartial; + complete: false; + missing: MissingTree; +}; + // @public (undocumented) type WatchQueryFetchPolicy = FetchPolicy | "cache-and-network"; diff --git a/.api-reports/api-report-react_internal.md b/.api-reports/api-report-react_internal.md index 9b76bda9bbc..b08b1bc6ba2 100644 --- a/.api-reports/api-report-react_internal.md +++ b/.api-reports/api-report-react_internal.md @@ -78,6 +78,10 @@ abstract class ApolloCache implements DataProxy { updateQuery(options: Cache_2.UpdateQueryOptions, update: (data: TData | null) => TData | null | void): TData | null; // (undocumented) abstract watch(watch: Cache_2.WatchOptions): () => 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(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "Reference" needs to be exported by the entry point index.d.ts // // (undocumented) @@ -88,14 +92,10 @@ abstract class ApolloCache implements DataProxy { writeQuery({ id, data, ...options }: Cache_2.WriteQueryOptions): Reference | undefined; } -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" -// // @public class ApolloClient implements DataProxy { // (undocumented) __actionHookForDevTools(cb: () => any): void; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloClient" constructor(options: ApolloClientOptions); // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // @@ -134,7 +134,6 @@ class ApolloClient implements DataProxy { onResetStore(cb: () => Promise): () => void; // Warning: (ae-forgotten-export) The symbol "QueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ApolloQueryResult" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "QueryOptions" query(options: QueryOptions): Promise>; // (undocumented) queryDeduplication: boolean; @@ -152,7 +151,6 @@ class ApolloClient implements DataProxy { setResolvers(resolvers: Resolvers | Resolvers[]): void; stop(): void; // Warning: (ae-forgotten-export) The symbol "SubscriptionOptions" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" subscribe(options: SubscriptionOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "ApolloClientOptions" needs to be exported by the entry point index.d.ts // @@ -160,11 +158,9 @@ class ApolloClient implements DataProxy { readonly typeDefs: ApolloClientOptions["typeDefs"]; // (undocumented) version: string; - // Warning: (ae-forgotten-export) The symbol "OperationVariables" needs to be exported by the entry point index.d.ts + watchFragment(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "WatchQueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ObservableQuery" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" watchQuery(options: WatchQueryOptions): ObservableQuery; writeFragment(options: DataProxy.WriteFragmentOptions): Reference | undefined; writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; @@ -185,7 +181,6 @@ interface ApolloClientOptions { // (undocumented) fragmentMatcher?: FragmentMatcher; headers?: Record; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" link?: ApolloLink; name?: string; queryDeduplication?: boolean; @@ -2023,6 +2018,28 @@ interface UseSuspenseQueryResult; } +// @public +interface WatchFragmentOptions { + // @deprecated (undocumented) + canonizeResults?: boolean; + fragment: DocumentNode | TypedDocumentNode; + fragmentName?: string; + from: StoreObject | Reference | string; + optimistic?: boolean; + variables?: TVars; +} + +// @public +type WatchFragmentResult = { + data: TData; + complete: true; + missing?: never; +} | { + data: DeepPartial; + complete: false; + missing: MissingTree; +}; + // @public (undocumented) type WatchQueryFetchPolicy = FetchPolicy | "cache-and-network"; diff --git a/.api-reports/api-report-react_ssr.md b/.api-reports/api-report-react_ssr.md index 3747959ed85..21c4a42669a 100644 --- a/.api-reports/api-report-react_ssr.md +++ b/.api-reports/api-report-react_ssr.md @@ -79,6 +79,10 @@ abstract class ApolloCache implements DataProxy { updateQuery(options: Cache_2.UpdateQueryOptions, update: (data: TData | null) => TData | null | void): TData | null; // (undocumented) abstract watch(watch: Cache_2.WatchOptions): () => 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(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "Reference" needs to be exported by the entry point index.d.ts // // (undocumented) @@ -89,14 +93,10 @@ abstract class ApolloCache implements DataProxy { writeQuery({ id, data, ...options }: Cache_2.WriteQueryOptions): Reference | undefined; } -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" -// // @public class ApolloClient implements DataProxy { // (undocumented) __actionHookForDevTools(cb: () => any): void; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloClient" constructor(options: ApolloClientOptions); // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // @@ -135,7 +135,6 @@ class ApolloClient implements DataProxy { onResetStore(cb: () => Promise): () => void; // Warning: (ae-forgotten-export) The symbol "QueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ApolloQueryResult" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "QueryOptions" query(options: QueryOptions): Promise>; // (undocumented) queryDeduplication: boolean; @@ -153,7 +152,6 @@ class ApolloClient implements DataProxy { setResolvers(resolvers: Resolvers | Resolvers[]): void; stop(): void; // Warning: (ae-forgotten-export) The symbol "SubscriptionOptions" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" subscribe(options: SubscriptionOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "ApolloClientOptions" needs to be exported by the entry point index.d.ts // @@ -161,11 +159,9 @@ class ApolloClient implements DataProxy { readonly typeDefs: ApolloClientOptions["typeDefs"]; // (undocumented) version: string; - // Warning: (ae-forgotten-export) The symbol "OperationVariables" needs to be exported by the entry point index.d.ts + watchFragment(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "WatchQueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ObservableQuery" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" watchQuery(options: WatchQueryOptions): ObservableQuery; writeFragment(options: DataProxy.WriteFragmentOptions): Reference | undefined; writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; @@ -186,7 +182,6 @@ interface ApolloClientOptions { // (undocumented) fragmentMatcher?: FragmentMatcher; headers?: Record; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" link?: ApolloLink; name?: string; queryDeduplication?: boolean; @@ -532,6 +527,40 @@ interface DataProxy { writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; } +// Warning: (ae-forgotten-export) The symbol "DeepPartialPrimitive" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialMap" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlyMap" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialSet" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlySet" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialObject" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartial = T extends DeepPartialPrimitive ? T : T extends Map ? DeepPartialMap : T extends ReadonlyMap ? DeepPartialReadonlyMap : T extends Set ? DeepPartialSet : T extends ReadonlySet ? DeepPartialReadonlySet : T extends (...args: any[]) => unknown ? T | undefined : T extends object ? T extends (ReadonlyArray) ? TItem[] extends (T) ? readonly TItem[] extends T ? ReadonlyArray> : Array> : DeepPartialObject : DeepPartialObject : unknown; + +// Warning: (ae-forgotten-export) The symbol "DeepPartial" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartialMap = {} & Map, DeepPartial>; + +// @public (undocumented) +type DeepPartialObject = { + [K in keyof T]?: DeepPartial; +}; + +// Warning: (ae-forgotten-export) The symbol "Primitive" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartialPrimitive = Primitive | Date | RegExp; + +// @public (undocumented) +type DeepPartialReadonlyMap = {} & ReadonlyMap, DeepPartial>; + +// @public (undocumented) +type DeepPartialReadonlySet = {} & ReadonlySet>; + +// @public (undocumented) +type DeepPartialSet = {} & Set>; + // @public (undocumented) interface DefaultContext extends Record { } @@ -1127,6 +1156,9 @@ type OperationVariables = Record; // @public (undocumented) type Path = ReadonlyArray; +// @public (undocumented) +type Primitive = null | undefined | string | number | boolean | symbol | bigint; + // @public (undocumented) interface QueryData { // (undocumented) @@ -1620,6 +1652,28 @@ interface UriFunction { (operation: Operation): string; } +// @public +interface WatchFragmentOptions { + // @deprecated (undocumented) + canonizeResults?: boolean; + fragment: DocumentNode | TypedDocumentNode; + fragmentName?: string; + from: StoreObject | Reference | string; + optimistic?: boolean; + variables?: TVars; +} + +// @public +type WatchFragmentResult = { + data: TData; + complete: true; + missing?: never; +} | { + data: DeepPartial; + complete: false; + missing: MissingTree; +}; + // @public (undocumented) type WatchQueryFetchPolicy = FetchPolicy | "cache-and-network"; diff --git a/.api-reports/api-report-testing.md b/.api-reports/api-report-testing.md index 343bb599d38..a9484356dde 100644 --- a/.api-reports/api-report-testing.md +++ b/.api-reports/api-report-testing.md @@ -79,6 +79,10 @@ abstract class ApolloCache implements DataProxy { updateQuery(options: Cache_2.UpdateQueryOptions, update: (data: TData | null) => TData | null | void): TData | null; // (undocumented) abstract watch(watch: Cache_2.WatchOptions): () => 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(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "Reference" needs to be exported by the entry point index.d.ts // // (undocumented) @@ -89,14 +93,10 @@ abstract class ApolloCache implements DataProxy { writeQuery({ id, data, ...options }: Cache_2.WriteQueryOptions): Reference | undefined; } -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" -// // @public class ApolloClient implements DataProxy { // (undocumented) __actionHookForDevTools(cb: () => any): void; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloClient" constructor(options: ApolloClientOptions); // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // @@ -135,7 +135,6 @@ class ApolloClient implements DataProxy { onResetStore(cb: () => Promise): () => void; // Warning: (ae-forgotten-export) The symbol "QueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ApolloQueryResult" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "QueryOptions" query(options: QueryOptions): Promise>; // (undocumented) queryDeduplication: boolean; @@ -153,7 +152,6 @@ class ApolloClient implements DataProxy { setResolvers(resolvers: Resolvers | Resolvers[]): void; stop(): void; // Warning: (ae-forgotten-export) The symbol "SubscriptionOptions" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" subscribe(options: SubscriptionOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "ApolloClientOptions" needs to be exported by the entry point index.d.ts // @@ -161,11 +159,9 @@ class ApolloClient implements DataProxy { readonly typeDefs: ApolloClientOptions["typeDefs"]; // (undocumented) version: string; - // Warning: (ae-forgotten-export) The symbol "OperationVariables" needs to be exported by the entry point index.d.ts + watchFragment(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "WatchQueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ObservableQuery" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" watchQuery(options: WatchQueryOptions): ObservableQuery; writeFragment(options: DataProxy.WriteFragmentOptions): Reference | undefined; writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; @@ -186,7 +182,6 @@ interface ApolloClientOptions { // (undocumented) fragmentMatcher?: FragmentMatcher; headers?: Record; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" link?: ApolloLink; name?: string; queryDeduplication?: boolean; @@ -527,6 +522,40 @@ interface DataProxy { writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; } +// Warning: (ae-forgotten-export) The symbol "DeepPartialPrimitive" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialMap" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlyMap" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialSet" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlySet" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialObject" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartial = T extends DeepPartialPrimitive ? T : T extends Map ? DeepPartialMap : T extends ReadonlyMap ? DeepPartialReadonlyMap : T extends Set ? DeepPartialSet : T extends ReadonlySet ? DeepPartialReadonlySet : T extends (...args: any[]) => unknown ? T | undefined : T extends object ? T extends (ReadonlyArray) ? TItem[] extends (T) ? readonly TItem[] extends T ? ReadonlyArray> : Array> : DeepPartialObject : DeepPartialObject : unknown; + +// Warning: (ae-forgotten-export) The symbol "DeepPartial" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartialMap = {} & Map, DeepPartial>; + +// @public (undocumented) +type DeepPartialObject = { + [K in keyof T]?: DeepPartial; +}; + +// Warning: (ae-forgotten-export) The symbol "Primitive" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartialPrimitive = Primitive | Date | RegExp; + +// @public (undocumented) +type DeepPartialReadonlyMap = {} & ReadonlyMap, DeepPartial>; + +// @public (undocumented) +type DeepPartialReadonlySet = {} & ReadonlySet>; + +// @public (undocumented) +type DeepPartialSet = {} & Set>; + // @public (undocumented) interface DefaultContext extends Record { } @@ -1234,6 +1263,9 @@ type OperationVariables = Record; // @public (undocumented) type Path = ReadonlyArray; +// @public (undocumented) +type Primitive = null | undefined | string | number | boolean | symbol | bigint; + // @public (undocumented) class QueryInfo { constructor(queryManager: QueryManager, queryId?: string); @@ -1671,6 +1703,28 @@ type VariableMatcher> = (variables: V) => boolean; // @public (undocumented) export function wait(ms: number): Promise; +// @public +interface WatchFragmentOptions { + // @deprecated (undocumented) + canonizeResults?: boolean; + fragment: DocumentNode | TypedDocumentNode; + fragmentName?: string; + from: StoreObject | Reference | string; + optimistic?: boolean; + variables?: TVars; +} + +// @public +type WatchFragmentResult = { + data: TData; + complete: true; + missing?: never; +} | { + data: DeepPartial; + complete: false; + missing: MissingTree; +}; + // @public (undocumented) type WatchQueryFetchPolicy = FetchPolicy | "cache-and-network"; diff --git a/.api-reports/api-report-testing_core.md b/.api-reports/api-report-testing_core.md index c8121f60b5b..0f5badbd21f 100644 --- a/.api-reports/api-report-testing_core.md +++ b/.api-reports/api-report-testing_core.md @@ -78,6 +78,10 @@ abstract class ApolloCache implements DataProxy { updateQuery(options: Cache_2.UpdateQueryOptions, update: (data: TData | null) => TData | null | void): TData | null; // (undocumented) abstract watch(watch: Cache_2.WatchOptions): () => 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(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "Reference" needs to be exported by the entry point index.d.ts // // (undocumented) @@ -88,14 +92,10 @@ abstract class ApolloCache implements DataProxy { writeQuery({ id, data, ...options }: Cache_2.WriteQueryOptions): Reference | undefined; } -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" -// // @public class ApolloClient implements DataProxy { // (undocumented) __actionHookForDevTools(cb: () => any): void; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloClient" constructor(options: ApolloClientOptions); // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // @@ -134,7 +134,6 @@ class ApolloClient implements DataProxy { onResetStore(cb: () => Promise): () => void; // Warning: (ae-forgotten-export) The symbol "QueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ApolloQueryResult" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "QueryOptions" query(options: QueryOptions): Promise>; // (undocumented) queryDeduplication: boolean; @@ -152,7 +151,6 @@ class ApolloClient implements DataProxy { setResolvers(resolvers: Resolvers | Resolvers[]): void; stop(): void; // Warning: (ae-forgotten-export) The symbol "SubscriptionOptions" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "Observable" subscribe(options: SubscriptionOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "ApolloClientOptions" needs to be exported by the entry point index.d.ts // @@ -160,11 +158,9 @@ class ApolloClient implements DataProxy { readonly typeDefs: ApolloClientOptions["typeDefs"]; // (undocumented) version: string; - // Warning: (ae-forgotten-export) The symbol "OperationVariables" needs to be exported by the entry point index.d.ts + watchFragment(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "WatchQueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ObservableQuery" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" watchQuery(options: WatchQueryOptions): ObservableQuery; writeFragment(options: DataProxy.WriteFragmentOptions): Reference | undefined; writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; @@ -185,7 +181,6 @@ interface ApolloClientOptions { // (undocumented) fragmentMatcher?: FragmentMatcher; headers?: Record; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" link?: ApolloLink; name?: string; queryDeduplication?: boolean; @@ -526,6 +521,40 @@ interface DataProxy { writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; } +// Warning: (ae-forgotten-export) The symbol "DeepPartialPrimitive" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialMap" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlyMap" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialSet" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialReadonlySet" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "DeepPartialObject" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartial = T extends DeepPartialPrimitive ? T : T extends Map ? DeepPartialMap : T extends ReadonlyMap ? DeepPartialReadonlyMap : T extends Set ? DeepPartialSet : T extends ReadonlySet ? DeepPartialReadonlySet : T extends (...args: any[]) => unknown ? T | undefined : T extends object ? T extends (ReadonlyArray) ? TItem[] extends (T) ? readonly TItem[] extends T ? ReadonlyArray> : Array> : DeepPartialObject : DeepPartialObject : unknown; + +// Warning: (ae-forgotten-export) The symbol "DeepPartial" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartialMap = {} & Map, DeepPartial>; + +// @public (undocumented) +type DeepPartialObject = { + [K in keyof T]?: DeepPartial; +}; + +// Warning: (ae-forgotten-export) The symbol "Primitive" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type DeepPartialPrimitive = Primitive | Date | RegExp; + +// @public (undocumented) +type DeepPartialReadonlyMap = {} & ReadonlyMap, DeepPartial>; + +// @public (undocumented) +type DeepPartialReadonlySet = {} & ReadonlySet>; + +// @public (undocumented) +type DeepPartialSet = {} & Set>; + // @public (undocumented) interface DefaultContext extends Record { } @@ -1189,6 +1218,9 @@ type OperationVariables = Record; // @public (undocumented) type Path = ReadonlyArray; +// @public (undocumented) +type Primitive = null | undefined | string | number | boolean | symbol | bigint; + // @public (undocumented) class QueryInfo { constructor(queryManager: QueryManager, queryId?: string); @@ -1628,6 +1660,28 @@ type VariableMatcher> = (variables: V) => boolean; // @public (undocumented) export function wait(ms: number): Promise; +// @public +interface WatchFragmentOptions { + // @deprecated (undocumented) + canonizeResults?: boolean; + fragment: DocumentNode | TypedDocumentNode; + fragmentName?: string; + from: StoreObject | Reference | string; + optimistic?: boolean; + variables?: TVars; +} + +// @public +type WatchFragmentResult = { + data: TData; + complete: true; + missing?: never; +} | { + data: DeepPartial; + complete: false; + missing: MissingTree; +}; + // @public (undocumented) type WatchQueryFetchPolicy = FetchPolicy | "cache-and-network"; diff --git a/.api-reports/api-report-utilities.md b/.api-reports/api-report-utilities.md index b47dd5550a0..8dde27dbc41 100644 --- a/.api-reports/api-report-utilities.md +++ b/.api-reports/api-report-utilities.md @@ -94,6 +94,10 @@ abstract class ApolloCache implements DataProxy { updateQuery(options: Cache_2.UpdateQueryOptions, update: (data: TData | null) => TData | null | void): TData | null; // (undocumented) abstract watch(watch: Cache_2.WatchOptions): () => 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(options: WatchFragmentOptions): Observable>; // (undocumented) abstract write(write: Cache_2.WriteOptions): Reference | undefined; // (undocumented) @@ -102,14 +106,10 @@ abstract class ApolloCache implements DataProxy { writeQuery({ id, data, ...options }: Cache_2.WriteQueryOptions): Reference | undefined; } -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" -// Warning: (ae-unresolved-link) The @link reference could not be resolved: This type of declaration is not supported yet by the resolver -// // @public class ApolloClient implements DataProxy { // (undocumented) __actionHookForDevTools(cb: () => any): void; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloClient" constructor(options: ApolloClientOptions); // Warning: (ae-forgotten-export) The symbol "GraphQLRequest" needs to be exported by the entry point index.d.ts // @@ -147,7 +147,6 @@ class ApolloClient implements DataProxy { onResetStore(cb: () => Promise): () => void; // Warning: (ae-forgotten-export) The symbol "QueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ApolloQueryResult" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "QueryOptions" query(options: QueryOptions): Promise>; // (undocumented) queryDeduplication: boolean; @@ -165,7 +164,6 @@ class ApolloClient implements DataProxy { setResolvers(resolvers: Resolvers | Resolvers[]): void; stop(): void; // Warning: (ae-forgotten-export) The symbol "SubscriptionOptions" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: This type of declaration is not supported yet by the resolver subscribe(options: SubscriptionOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "ApolloClientOptions" needs to be exported by the entry point index.d.ts // @@ -173,11 +171,9 @@ class ApolloClient implements DataProxy { readonly typeDefs: ApolloClientOptions["typeDefs"]; // (undocumented) version: string; - // Warning: (ae-forgotten-export) The symbol "OperationVariables" needs to be exported by the entry point index.d.ts + watchFragment(options: WatchFragmentOptions): Observable>; // Warning: (ae-forgotten-export) The symbol "WatchQueryOptions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ObservableQuery" needs to be exported by the entry point index.d.ts - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ObservableQuery" watchQuery(options: WatchQueryOptions): ObservableQuery; writeFragment(options: DataProxy.WriteFragmentOptions): Reference | undefined; writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; @@ -198,7 +194,6 @@ interface ApolloClientOptions { // (undocumented) fragmentMatcher?: FragmentMatcher; headers?: Record; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@apollo/client" does not have an export "ApolloLink" link?: ApolloLink; name?: string; queryDeduplication?: boolean; @@ -2577,6 +2572,28 @@ export function valueToObjectRepresentation(argObj: any, name: NameNode, value: // @public (undocumented) export type VariableValue = (node: VariableNode) => any; +// @public +interface WatchFragmentOptions { + // @deprecated (undocumented) + canonizeResults?: boolean; + fragment: DocumentNode | TypedDocumentNode; + fragmentName?: string; + from: StoreObject | Reference | string; + optimistic?: boolean; + variables?: TVars; +} + +// @public +type WatchFragmentResult = { + data: TData; + complete: true; + missing?: never; +} | { + data: DeepPartial; + complete: false; + missing: MissingTree; +}; + // @public (undocumented) type WatchQueryFetchPolicy = FetchPolicy | "cache-and-network"; diff --git a/.api-reports/api-report.md b/.api-reports/api-report.md index 1d09c28f12b..f2c04199b74 100644 --- a/.api-reports/api-report.md +++ b/.api-reports/api-report.md @@ -81,6 +81,9 @@ export abstract class ApolloCache implements DataProxy { updateQuery(options: Cache_2.UpdateQueryOptions, update: (data: TData | null) => TData | null | void): TData | null; // (undocumented) abstract watch(watch: Cache_2.WatchOptions): () => 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(options: WatchFragmentOptions): Observable>; // (undocumented) abstract write(write: Cache_2.WriteOptions): Reference | undefined; // (undocumented) @@ -89,8 +92,6 @@ export abstract class ApolloCache implements DataProxy { writeQuery({ id, data, ...options }: Cache_2.WriteQueryOptions): Reference | undefined; } -// Warning: (ae-unresolved-link) The @link reference could not be resolved: This type of declaration is not supported yet by the resolver -// // @public export class ApolloClient implements DataProxy { // (undocumented) @@ -132,12 +133,12 @@ export class ApolloClient implements DataProxy { setLocalStateFragmentMatcher(fragmentMatcher: FragmentMatcher): void; setResolvers(resolvers: Resolvers | Resolvers[]): void; stop(): void; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: This type of declaration is not supported yet by the resolver subscribe(options: SubscriptionOptions): Observable>; // (undocumented) readonly typeDefs: ApolloClientOptions["typeDefs"]; // (undocumented) version: string; + watchFragment(options: WatchFragmentOptions): Observable>; watchQuery(options: WatchQueryOptions): ObservableQuery; writeFragment(options: DataProxy.WriteFragmentOptions): Reference | undefined; writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; @@ -3022,6 +3023,28 @@ TVariables variables: TVariables; }; +// @public +interface WatchFragmentOptions { + // @deprecated (undocumented) + canonizeResults?: boolean; + fragment: DocumentNode | TypedDocumentNode; + fragmentName?: string; + from: StoreObject | Reference | string; + optimistic?: boolean; + variables?: TVars; +} + +// @public +type WatchFragmentResult = { + data: TData; + complete: true; + missing?: never; +} | { + data: DeepPartial; + complete: false; + missing: MissingTree; +}; + // @public (undocumented) export type WatchQueryFetchPolicy = FetchPolicy | "cache-and-network"; diff --git a/.changeset/tasty-pillows-ring.md b/.changeset/tasty-pillows-ring.md new file mode 100644 index 00000000000..5c0f9643bb5 --- /dev/null +++ b/.changeset/tasty-pillows-ring.md @@ -0,0 +1,5 @@ +--- +"@apollo/client": minor +--- + +Add `watchFragment` method to the cache and expose it on ApolloClient, refactor `useFragment` using `watchFragment`. diff --git a/.size-limits.json b/.size-limits.json index cdae2c9cd42..dd93933136b 100644 --- a/.size-limits.json +++ b/.size-limits.json @@ -1,4 +1,4 @@ { - "dist/apollo-client.min.cjs": 39247, - "import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32630 + "dist/apollo-client.min.cjs": 39403, + "import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32788 } diff --git a/config/inlineInheritDoc.ts b/config/inlineInheritDoc.ts index 704054f28ec..0bb126629ae 100644 --- a/config/inlineInheritDoc.ts +++ b/config/inlineInheritDoc.ts @@ -143,6 +143,7 @@ function processComments() { if ( Node.isPropertySignature(node) || Node.isMethodSignature(node) || + Node.isMethodDeclaration(node) || Node.isCallSignatureDeclaration(node) ) { const docsNode = node.getJsDocs()[0]; diff --git a/docs/README.md b/docs/README.md index cb9d3ba95d3..9410556e966 100644 --- a/docs/README.md +++ b/docs/README.md @@ -6,4 +6,13 @@ The **deployed** version of the documentation for this repository is available a * https://www.apollographql.com/docs/react/ -See the [docs site README](https://github.com/apollographql/docs) for local installation and development. +For general local installation and development instructions, see the [docs site README](https://github.com/apollographql/docs). + +In order to build and develop the Apollo Client docs locally, you will need to follow these additional steps: + +1. Clone the docs site repository ([https://github.com/apollographql/docs](https://github.com/apollographql/docs)) in a sibling directory to your local copy of the [`apollo-client`](https://github.com/apollographql/apollo-client) repository. +2. `cd docs && npm i` +3. Open a new terminal, `cd apollo-client`, make changes to the docs and run `npm run docmodel` +4. Back in the terminal window where you've checked out and cd'd into the `docs` repository, run `DOCS_MODE='local' npm run start:local -- ../apollo-client` +5. Open a browser and visit `http://localhost:3000` +6. Note: you'll need to manually remove the `/react` segment of the URL from the path inside the browser diff --git a/docs/source/api/cache/InMemoryCache.mdx b/docs/source/api/cache/InMemoryCache.mdx index 7bcc362d9ea..4891eef7b01 100644 --- a/docs/source/api/cache/InMemoryCache.mdx +++ b/docs/source/api/cache/InMemoryCache.mdx @@ -2,8 +2,12 @@ title: class InMemoryCache description: API reference api_reference: true +api_doc: + - "@apollo/client!ApolloClient#watchFragment:member(1)" --- +import { FunctionDetails, DocBlock, Example } from '../../../shared/ApiDoc'; + Methods of the `InMemoryCache` class (the cache used by almost every instance of [`ApolloClient`](../core/ApolloClient/)) are documented here. > Before reading about individual methods, see [Caching in Apollo Client](../../caching/overview/). @@ -768,6 +772,9 @@ writeFragment( options: Cache.WriteFragmentOptions, ): Reference | undefined ``` + + + ## `updateFragment` diff --git a/docs/source/api/core/ApolloClient.mdx b/docs/source/api/core/ApolloClient.mdx index 752f6633d9e..0294973a18e 100644 --- a/docs/source/api/core/ApolloClient.mdx +++ b/docs/source/api/core/ApolloClient.mdx @@ -36,6 +36,7 @@ For more information on the `defaultOptions` object, see the [Default Options](# + diff --git a/docs/source/api/core/ObservableQuery.mdx b/docs/source/api/core/ObservableQuery.mdx index 806091f8b28..89c5448be7e 100644 --- a/docs/source/api/core/ObservableQuery.mdx +++ b/docs/source/api/core/ObservableQuery.mdx @@ -1,6 +1,7 @@ --- title: ObservableQuery description: API reference +api_reference: true api_doc: - "@apollo/client!ObservableQuery:class" - "@apollo/client!ApolloQueryResult:interface" diff --git a/docs/source/caching/cache-interaction.mdx b/docs/source/caching/cache-interaction.mdx index 33baca6a11a..4331a5da14f 100644 --- a/docs/source/caching/cache-interaction.mdx +++ b/docs/source/caching/cache-interaction.mdx @@ -1,7 +1,11 @@ --- title: Reading and writing data to the cache +api_doc: + - "@apollo/client!ApolloClient#watchFragment:member(1)" --- +import { DocBlock } from '../../shared/ApiDoc'; + You can read and write data directly to the Apollo Client cache, _without_ communicating with your GraphQL server. You can interact with data that you previously fetched from your server, _and_ with data that's only available [locally](../local-state/local-state-management/). Apollo Client supports multiple strategies for interacting with cached data: @@ -211,6 +215,14 @@ client.writeFragment({ All subscribers to the Apollo Client cache (including all active queries) see this change and update your application's UI accordingly. + + +### `watchFragment` + + + + + ### `useFragment` diff --git a/netlify.toml b/netlify.toml index 510fb6a139b..363e4f0818d 100644 --- a/netlify.toml +++ b/netlify.toml @@ -2,9 +2,6 @@ publish = "docs/public" command = "npm run typedoc; npm run docmodel > docs/public/log.txt || true" -[build.environment] - NODE_VERSION = "18" - [context.deploy-preview.build] base = "docs" ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../src" diff --git a/src/__tests__/ApolloClient.ts b/src/__tests__/ApolloClient.ts index 993691abe0c..67ce0002714 100644 --- a/src/__tests__/ApolloClient.ts +++ b/src/__tests__/ApolloClient.ts @@ -14,7 +14,7 @@ import { ApolloLink } from "../link/core"; import { HttpLink } from "../link/http"; import { InMemoryCache } from "../cache"; import { itAsync } from "../testing"; -import { spyOnConsole } from "../testing/internal"; +import { ObservableStream, spyOnConsole } from "../testing/internal"; import { TypedDocumentNode } from "@graphql-typed-document-node/core"; import { invariant } from "../utilities/globals"; @@ -2174,6 +2174,263 @@ describe("ApolloClient", () => { ); }); + describe("watchFragment", () => { + it("if all data is available, `complete` is `true`", async () => { + const cache = new InMemoryCache(); + const client = new ApolloClient({ + cache, + link: ApolloLink.empty(), + }); + const ItemFragment = gql` + fragment ItemFragment on Item { + id + text + } + `; + + cache.writeFragment({ + fragment: ItemFragment, + data: { + __typename: "Item", + id: 5, + text: "Item #5", + }, + }); + + const observable = client.watchFragment({ + fragment: ItemFragment, + from: { __typename: "Item", id: 5 }, + }); + + const stream = new ObservableStream(observable); + + { + const result = await stream.takeNext(); + + expect(result).toEqual({ + data: { + __typename: "Item", + id: 5, + text: "Item #5", + }, + complete: true, + }); + } + }); + it("cache writes emit a new value", async () => { + const cache = new InMemoryCache(); + const client = new ApolloClient({ + cache, + link: ApolloLink.empty(), + }); + const ItemFragment = gql` + fragment ItemFragment on Item { + id + text + } + `; + + cache.writeFragment({ + fragment: ItemFragment, + data: { + __typename: "Item", + id: 5, + text: "Item #5", + }, + }); + + const observable = client.watchFragment({ + fragment: ItemFragment, + from: { __typename: "Item", id: 5 }, + }); + + const stream = new ObservableStream(observable); + + { + const result = await stream.takeNext(); + + expect(result).toEqual({ + data: { + __typename: "Item", + id: 5, + text: "Item #5", + }, + complete: true, + }); + } + + cache.writeFragment({ + fragment: ItemFragment, + data: { + __typename: "Item", + id: 5, + text: "Item #5 (edited)", + }, + }); + + { + const result = await stream.takeNext(); + + expect(result).toEqual({ + data: { + __typename: "Item", + id: 5, + text: "Item #5 (edited)", + }, + complete: true, + }); + } + }); + it("if only partial data is available, `complete` is `false`", async () => { + const cache = new InMemoryCache(); + const client = new ApolloClient({ + cache, + link: ApolloLink.empty(), + }); + const ItemFragment = gql` + fragment ItemFragment on Item { + id + text + } + `; + + { + // we expect a "Missing field 'text' while writing result..." error + // when writing item to the cache, so we'll silence the console.error + using _consoleSpy = spyOnConsole("error"); + cache.writeFragment({ + fragment: ItemFragment, + data: { + __typename: "Item", + id: 5, + }, + }); + } + + const observable = client.watchFragment({ + fragment: ItemFragment, + from: { __typename: "Item", id: 5 }, + }); + + const stream = new ObservableStream(observable); + + { + const result = await stream.takeNext(); + + expect(result).toEqual({ + data: { + __typename: "Item", + id: 5, + }, + complete: false, + missing: { + text: "Can't find field 'text' on Item:5 object", + }, + }); + } + }); + it("if no data is written after observable is subscribed to, next is never called", async () => { + const cache = new InMemoryCache(); + const client = new ApolloClient({ + cache, + link: ApolloLink.empty(), + }); + const ItemFragment = gql` + fragment ItemFragment on Item { + id + text + } + `; + + const observable = client.watchFragment({ + fragment: ItemFragment, + from: { __typename: "Item", id: 5 }, + }); + + const stream = new ObservableStream(observable); + + { + const result = await stream.takeNext(); + + expect(result).toEqual({ + complete: false, + data: {}, + missing: "Dangling reference to missing Item:5 object", + }); + } + + await expect(stream.takeNext({ timeout: 1000 })).rejects.toEqual( + expect.any(Error) + ); + }); + // The @nonreactive directive can only be used on fields or fragment + // spreads in queries, and currently has no effect here + it.failing("does not support the @nonreactive directive", async () => { + const cache = new InMemoryCache(); + const client = new ApolloClient({ + cache, + link: ApolloLink.empty(), + }); + const ItemFragment = gql` + fragment ItemFragment on Item { + id + text @nonreactive + } + `; + + cache.writeFragment({ + fragment: ItemFragment, + data: { + __typename: "Item", + id: 5, + text: "Item #5", + }, + }); + + const observable = client.watchFragment({ + fragment: ItemFragment, + from: { __typename: "Item", id: 5 }, + }); + + const stream = new ObservableStream(observable); + + { + const result = await stream.takeNext(); + + expect(result).toEqual({ + data: { + __typename: "Item", + id: 5, + text: "Item #5", + }, + complete: true, + }); + } + + cache.writeFragment({ + fragment: ItemFragment, + data: { + __typename: "Item", + id: 5, + text: "Item #5 (edited)", + }, + }); + + { + const result = await stream.takeNext(); + + expect(result).toEqual({ + data: { + __typename: "Item", + id: 5, + text: "Item #5", + }, + complete: true, + }); + } + }); + }); + describe("defaultOptions", () => { it( "should set `defaultOptions` to an empty object if not provided in " + diff --git a/src/cache/core/cache.ts b/src/cache/core/cache.ts index a0fd1778bdc..6c9e4108223 100644 --- a/src/cache/core/cache.ts +++ b/src/cache/core/cache.ts @@ -1,19 +1,102 @@ import type { DocumentNode } from "graphql"; import { wrap } from "optimism"; -import type { StoreObject, Reference } from "../../utilities/index.js"; +import type { + StoreObject, + Reference, + DeepPartial, +} from "../../utilities/index.js"; import { + Observable, cacheSizes, defaultCacheSizes, getFragmentQueryDocument, + mergeDeepArray, } from "../../utilities/index.js"; import type { DataProxy } from "./types/DataProxy.js"; import type { Cache } from "./types/Cache.js"; import { WeakCache } from "@wry/caches"; import { getApolloCacheMemoryInternals } from "../../utilities/caching/getMemoryInternals.js"; +import type { + OperationVariables, + TypedDocumentNode, +} from "../../core/types.js"; +import { equal } from "@wry/equality"; +import type { MissingTree } from "./types/common.js"; export type Transaction = (c: ApolloCache) => void; +/** + * Watched fragment options. + */ +export interface WatchFragmentOptions { + /** + * A GraphQL fragment document parsed into an AST with the `gql` + * template literal. + * + * @docGroup 1. Required options + */ + fragment: DocumentNode | TypedDocumentNode; + /** + * An object containing a `__typename` and primary key fields + * (such as `id`) identifying the entity object from which the fragment will + * be retrieved, or a `{ __ref: "..." }` reference, or a `string` ID + * (uncommon). + * + * @docGroup 1. Required options + */ + from: StoreObject | Reference | string; + /** + * Any variables that the GraphQL fragment may depend on. + * + * @docGroup 2. Cache options + */ + variables?: TVars; + /** + * The name of the fragment defined in the fragment document. + * + * Required if the fragment document includes more than one fragment, + * optional otherwise. + * + * @docGroup 2. Cache options + */ + fragmentName?: string; + /** + * If `true`, `watchFragment` returns optimistic results. + * + * The default value is `true`. + * + * @docGroup 2. Cache options + */ + optimistic?: boolean; + /** + * @deprecated + * Using `canonizeResults` can result in memory leaks so we generally do not + * recommend using this option anymore. + * A future version of Apollo Client will contain a similar feature. + * + * Whether to canonize cache results before returning them. Canonization + * takes some extra time, but it speeds up future deep equality comparisons. + * Defaults to false. + */ + canonizeResults?: boolean; +} + +/** + * Watched fragment results. + */ +export type WatchFragmentResult = + | { + data: TData; + complete: true; + missing?: never; + } + | { + data: DeepPartial; + complete: false; + missing: MissingTree; + }; + export abstract class ApolloCache implements DataProxy { public readonly assumeImmutableResults: boolean = false; @@ -141,6 +224,49 @@ export abstract class ApolloCache implements DataProxy { }); } + /** {@inheritDoc @apollo/client!ApolloClient#watchFragment:member(1)} */ + public watchFragment( + options: WatchFragmentOptions + ): Observable> { + const { fragment, fragmentName, from, optimistic = true } = options; + + const diffOptions: Cache.DiffOptions = { + returnPartialData: true, + id: typeof from === "string" ? from : this.identify(from), + query: this.getFragmentDoc(fragment, fragmentName), + optimistic, + }; + + let latestDiff: DataProxy.DiffResult | undefined; + + return new Observable((observer) => { + return this.watch({ + ...diffOptions, + immediate: true, + query: this.getFragmentDoc(fragment, fragmentName), + callback(diff) { + if (equal(diff, latestDiff)) { + return; + } + + const result = { + data: diff.result as DeepPartial, + complete: !!diff.complete, + } as WatchFragmentResult; + + if (diff.missing) { + result.missing = mergeDeepArray( + diff.missing.map((error) => error.missing) + ); + } + + latestDiff = diff; + observer.next(result); + }, + }); + }); + } + // Make sure we compute the same (===) fragment query document every // time we receive the same fragment in readFragment. private getFragmentDoc = wrap(getFragmentQueryDocument, { diff --git a/src/core/ApolloClient.ts b/src/core/ApolloClient.ts index e564a249c10..53abab69401 100644 --- a/src/core/ApolloClient.ts +++ b/src/core/ApolloClient.ts @@ -58,7 +58,7 @@ export interface ApolloClientOptions { */ headers?: Record; /** - * You can provide an {@link ApolloLink} instance to serve as Apollo Client's network layer. For more information, see [Advanced HTTP networking](https://www.apollographql.com/docs/react/networking/advanced-http-networking/). + * You can provide an `ApolloLink` instance to serve as Apollo Client's network layer. For more information, see [Advanced HTTP networking](https://www.apollographql.com/docs/react/networking/advanced-http-networking/). * * One of `uri` or `link` is **required**. If you provide both, `link` takes precedence. */ @@ -128,13 +128,17 @@ export interface ApolloClientOptions { // solution is to reexport mergeOptions where it was previously declared (here). import { mergeOptions } from "../utilities/index.js"; import { getApolloClientMemoryInternals } from "../utilities/caching/getMemoryInternals.js"; +import type { + WatchFragmentOptions, + WatchFragmentResult, +} from "../cache/core/cache.js"; export { mergeOptions }; /** * This is the primary Apollo Client class. It is used to send GraphQL documents (i.e. queries - * and mutations) to a GraphQL spec-compliant server over an {@link ApolloLink} instance, + * and mutations) to a GraphQL spec-compliant server over an `ApolloLink` instance, * receive results from the server and cache the results in a store. It also delivers updates - * to GraphQL queries through {@link Observable} instances. + * to GraphQL queries through `Observable` instances. */ export class ApolloClient implements DataProxy { public link: ApolloLink; @@ -152,7 +156,7 @@ export class ApolloClient implements DataProxy { private localState: LocalState; /** - * Constructs an instance of {@link ApolloClient}. + * Constructs an instance of `ApolloClient`. * * @example * ```js @@ -354,8 +358,8 @@ export class ApolloClient implements DataProxy { /** * This watches the cache store of the query according to the options specified and - * returns an {@link ObservableQuery}. We can subscribe to this {@link ObservableQuery} and - * receive updated results through a GraphQL observer when the cache store changes. + * returns an `ObservableQuery`. We can subscribe to this `ObservableQuery` and + * receive updated results through an observer when the cache store changes. * * Note that this method is not an implementation of GraphQL subscriptions. Rather, * it uses Apollo's store in order to reactively deliver updates to your query results. @@ -396,7 +400,7 @@ export class ApolloClient implements DataProxy { * returns a `Promise` which is either resolved with the resulting data * or rejected with an error. * - * @param options - An object of type {@link QueryOptions} that allows us to + * @param options - An object of type `QueryOptions` that allows us to * describe how this query should be treated e.g. whether it should hit the * server at all or just resolve from the cache, etc. */ @@ -449,7 +453,7 @@ export class ApolloClient implements DataProxy { /** * This subscribes to a graphql subscription according to the options specified and returns an - * {@link Observable} which either emits received data or an error. + * `Observable` which either emits received data or an error. */ public subscribe< T = any, @@ -474,6 +478,32 @@ export class ApolloClient implements DataProxy { return this.cache.readQuery(options, optimistic); } + /** + * Watches the cache store of the fragment according to the options specified + * and returns an `Observable`. We can subscribe to this + * `Observable` and receive updated results through an + * observer when the cache store changes. + * + * You must pass in a GraphQL document with a single fragment or a document + * with multiple fragments that represent what you are reading. If you pass + * in a document with multiple fragments then you must also specify a + * `fragmentName`. + * + * @since 3.10.0 + * @param options - An object of type `WatchFragmentOptions` that allows + * the cache to identify the fragment and optionally specify whether to react + * to optimistic updates. + */ + + public watchFragment< + TFragmentData = unknown, + TVariables = OperationVariables, + >( + options: WatchFragmentOptions + ): Observable> { + return this.cache.watchFragment(options); + } + /** * Tries to read some data from the store in the shape of the provided * GraphQL fragment without making a network request. This method will read a diff --git a/src/react/hooks/useFragment.ts b/src/react/hooks/useFragment.ts index 96e2a1c014a..3c1425eecf7 100644 --- a/src/react/hooks/useFragment.ts +++ b/src/react/hooks/useFragment.ts @@ -1,6 +1,4 @@ import * as React from "rehackt"; -import { equal } from "@wry/equality"; - import type { DeepPartial } from "../../utilities/index.js"; import { mergeDeepArray } from "../../utilities/index.js"; import type { @@ -15,6 +13,7 @@ import { useSyncExternalStore } from "./useSyncExternalStore.js"; import type { ApolloClient, OperationVariables } from "../../core/index.js"; import type { NoInfer } from "../types/types.js"; import { useDeepMemo, useLazyRef, wrapHook } from "./internal/index.js"; +import equal from "@wry/equality"; export interface UseFragmentOptions extends Omit< @@ -88,6 +87,14 @@ function _useFragment( diffToResult(cache.diff(diffOptions)) ); + const stableOptions = useDeepMemo(() => options, [options]); + + // Since .next is async, we need to make sure that we + // get the correct diff on the next render given new diffOptions + React.useMemo(() => { + resultRef.current = diffToResult(cache.diff(diffOptions)); + }, [diffOptions, cache]); + // Used for both getSnapshot and getServerSnapshot const getSnapshot = React.useCallback(() => resultRef.current, []); @@ -95,27 +102,24 @@ function _useFragment( React.useCallback( (forceUpdate) => { let lastTimeout = 0; - const unsubscribe = cache.watch({ - ...diffOptions, - immediate: true, - callback(diff) { - if (!equal(diff.result, resultRef.current.data)) { - resultRef.current = diffToResult(diff); - // If we get another update before we've re-rendered, bail out of - // the update and try again. This ensures that the relative timing - // between useQuery and useFragment stays roughly the same as - // fixed in https://github.com/apollographql/apollo-client/pull/11083 - clearTimeout(lastTimeout); - lastTimeout = setTimeout(forceUpdate) as any; - } + const subscription = cache.watchFragment(stableOptions).subscribe({ + next: (result) => { + if (equal(result, resultRef.current)) return; + resultRef.current = result; + // If we get another update before we've re-rendered, bail out of + // the update and try again. This ensures that the relative timing + // between useQuery and useFragment stays roughly the same as + // fixed in https://github.com/apollographql/apollo-client/pull/11083 + clearTimeout(lastTimeout); + lastTimeout = setTimeout(forceUpdate) as any; }, }); return () => { - unsubscribe(); + subscription.unsubscribe(); clearTimeout(lastTimeout); }; }, - [cache, diffOptions] + [cache, stableOptions] ), getSnapshot, getSnapshot