diff --git a/.api-reports/api-report-core.api.md b/.api-reports/api-report-core.api.md index 700997521d5..d5f326579d3 100644 --- a/.api-reports/api-report-core.api.md +++ b/.api-reports/api-report-core.api.md @@ -2022,7 +2022,7 @@ interface WriteContext extends ReadMergeModifyContext { // src/cache/inmemory/types.ts:133:3 - (ae-forgotten-export) The symbol "KeyFieldsFunction" needs to be exported by the entry point index.d.ts // src/core/ObservableQuery.ts:130:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts // src/core/ObservableQuery.ts:131:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts -// src/core/QueryManager.ts:187:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts +// src/core/QueryManager.ts:185:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts // src/core/QueryManager.ts:455:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts // (No @packageDocumentation comment for this package) diff --git a/.api-reports/api-report-react.api.md b/.api-reports/api-report-react.api.md index 28e9f349d5a..56692c7b92e 100644 --- a/.api-reports/api-report-react.api.md +++ b/.api-reports/api-report-react.api.md @@ -4,51 +4,240 @@ ```ts -import type { ApolloCache } from '@apollo/client/core'; +import type { ApolloCache } from '@apollo/client/cache'; +import type { ApolloCache as ApolloCache_2 } from '@apollo/client/core'; import type { ApolloClient } from '@apollo/client/core'; -import { ApolloConsumer } from '@apollo/client/react/context'; -import { ApolloContextValue } from '@apollo/client/react/context'; -import { ApolloProvider } from '@apollo/client/react/context'; +import { ApolloLink } from '@apollo/client/link/core'; +import type { ApolloQueryResult as ApolloQueryResult_2 } from '@apollo/client/core'; +import type { ASTNode } from 'graphql'; +import type { Cache as Cache_2 } from '@apollo/client/cache'; +import type { DataProxy } from '@apollo/client/cache'; import type { DeepPartial } from '@apollo/client/utilities'; -import type { DefaultContext } from '@apollo/client/core'; -import type { DocumentNode } from '@apollo/client/core'; -import { DocumentType as DocumentType_2 } from '@apollo/client/react/parser'; -import type { ErrorPolicy } from '@apollo/client/core'; -import { getApolloContext } from '@apollo/client/react/context'; -import { IDocumentDefinition } from '@apollo/client/react/parser'; +import type { DefaultContext as DefaultContext_2 } from '@apollo/client/core'; +import type { DocumentNode } from 'graphql'; +import type { DocumentNode as DocumentNode_2 } from '@apollo/client/core'; +import { DocumentTransform } from '@apollo/client/utilities'; +import type { ErrorLike as ErrorLike_2 } from '@apollo/client/core'; +import type { ErrorPolicy as ErrorPolicy_2 } from '@apollo/client/core'; +import type { FetchMoreFunction } from '@apollo/client/react/internal'; +import type { FetchMoreQueryOptions as FetchMoreQueryOptions_2 } from '@apollo/client/core'; +import type { FetchPolicy as FetchPolicy_2 } from '@apollo/client/core'; +import type { FetchResult } from '@apollo/client/link/core'; +import type { FetchResult as FetchResult_2 } from '@apollo/client/core'; +import type { FieldNode } from 'graphql'; +import type { FormattedExecutionResult } from 'graphql'; +import type { FragmentMap } from '@apollo/client/utilities'; +import type { FragmentType } from '@apollo/client/masking'; +import { getApolloClientMemoryInternals } from '@apollo/client/utilities/internal'; +import type { GraphQLRequest } from '@apollo/client/link/core'; +import type { HookWrappers } from '@apollo/client/react/internal'; +import type { InternalRefetchQueriesInclude as InternalRefetchQueriesInclude_2 } from '@apollo/client/core'; +import type { InteropObservable } from 'rxjs'; +import type { IsStrictlyAny } from '@apollo/client/utilities'; +import type { MaybeMasked } from '@apollo/client/masking'; +import type { MaybeMasked as MaybeMasked_2 } from '@apollo/client/core'; +import type { MissingTree } from '@apollo/client/cache'; +import type { MutateResult as MutateResult_2 } from '@apollo/client/core'; +import type { MutationFetchPolicy as MutationFetchPolicy_2 } from '@apollo/client/core'; +import type { MutationQueryReducersMap as MutationQueryReducersMap_2 } from '@apollo/client/core'; +import type { MutationUpdaterFunction as MutationUpdaterFunction_2 } from '@apollo/client/core'; +import { NetworkStatus as NetworkStatus_2 } from '@apollo/client/core'; import type { NoInfer as NoInfer_2 } from '@apollo/client/utilities'; +import { Observable } from 'rxjs'; +import type { ObservableQuery as ObservableQuery_2 } from '@apollo/client/core'; +import type { Observer } from 'rxjs'; import type { OnlyRequiredProperties } from '@apollo/client/utilities'; -import { operationName } from '@apollo/client/react/parser'; +import type { OnQueryUpdated as OnQueryUpdated_2 } from '@apollo/client/core'; import type { OperationVariables } from '@apollo/client/core'; -import { parser } from '@apollo/client/react/parser'; import { PreloadedQueryRef } from '@apollo/client/react/internal'; import { QueryRef } from '@apollo/client/react/internal'; import { QueryReference } from '@apollo/client/react/internal'; -import type { RefetchWritePolicy } from '@apollo/client/core'; -import { SkipToken } from '@apollo/client/react/hooks'; -import { skipToken } from '@apollo/client/react/hooks'; -import type { TypedDocumentNode } from '@apollo/client/core'; -import { useApolloClient } from '@apollo/client/react/hooks'; -import { useBackgroundQuery } from '@apollo/client/react/hooks'; -import { useFragment } from '@apollo/client/react/hooks'; -import { useLazyQuery } from '@apollo/client/react/hooks'; -import { useLoadableQuery } from '@apollo/client/react/hooks'; -import { useMutation } from '@apollo/client/react/hooks'; -import { useQuery } from '@apollo/client/react/hooks'; -import { useQueryRefHandlers } from '@apollo/client/react/hooks'; -import { useReactiveVar } from '@apollo/client/react/hooks'; -import { useReadQuery } from '@apollo/client/react/hooks'; -import { useSubscription } from '@apollo/client/react/hooks'; -import { useSuspenseFragment } from '@apollo/client/react/hooks'; -import { useSuspenseQuery } from '@apollo/client/react/hooks'; +import type { QueryResult as QueryResult_3 } from '@apollo/client/core'; +import type { ReactiveVar } from '@apollo/client/core'; +import type * as ReactTypes from 'react'; +import type { Reference } from '@apollo/client/cache'; +import type { Reference as Reference_2 } from '@apollo/client/core'; +import type { RefetchFunction } from '@apollo/client/react/internal'; +import type { RefetchWritePolicy as RefetchWritePolicy_2 } from '@apollo/client/core'; +import type { StoreObject } from '@apollo/client/utilities'; +import type { StoreObject as StoreObject_2 } from '@apollo/client/cache'; +import type { StoreObject as StoreObject_3 } from '@apollo/client/core'; +import type { Subscribable } from 'rxjs'; +import type { SubscribeToMoreFunction } from '@apollo/client/core'; +import type { Subscription } from 'rxjs'; +import { Trie } from '@wry/trie'; +import { TypedDocumentNode } from '@graphql-typed-document-node/core'; +import type { TypedDocumentNode as TypedDocumentNode_2 } from '@apollo/client/core'; +import type { Unmasked } from '@apollo/client/masking'; +import type { Unmasked as Unmasked_2 } from '@apollo/client/core'; +import type { UpdateQueryMapFn as UpdateQueryMapFn_2 } from '@apollo/client/core'; +import type { UriFunction } from '@apollo/client/link/http'; import type { VariablesOption } from '@apollo/client/react/internal'; +import type { WatchFragmentOptions } from '@apollo/client/cache'; +import type { WatchFragmentResult } from '@apollo/client/cache'; import type { WatchQueryFetchPolicy } from '@apollo/client/core'; +import type { WatchQueryOptions } from '@apollo/client/core'; +import type { wrapperSymbol } from '@apollo/client/react/internal'; -export { ApolloConsumer } +// @public +class ApolloClient_2 implements DataProxy { + // (undocumented) + __actionHookForDevTools(cb: () => any): void; + constructor(options: ApolloClientOptions); + // (undocumented) + __requestRaw(payload: GraphQLRequest): Observable; + // Warning: (ae-forgotten-export) The symbol "Resolvers" needs to be exported by the entry point index.d.ts + addResolvers(resolvers: Resolvers | Resolvers[]): void; + // (undocumented) + cache: ApolloCache; + clearStore(): Promise; + // (undocumented) + get defaultContext(): Partial; + // (undocumented) + defaultOptions: DefaultOptions; + // Warning: (ae-forgotten-export) The symbol "DevtoolsOptions" needs to be exported by the entry point index.d.ts + // + // (undocumented) + readonly devtoolsConfig: DevtoolsOptions; + // @deprecated (undocumented) + disableNetworkFetches: never; + get documentTransform(): DocumentTransform; + extract(optimistic?: boolean): unknown; + getMemoryInternals?: typeof getApolloClientMemoryInternals; + // Warning: (ae-forgotten-export) The symbol "RefetchQueriesInclude" needs to be exported by the entry point index.d.ts + getObservableQueries(include?: RefetchQueriesInclude): Map>; + getResolvers(): Resolvers; + // (undocumented) + link: ApolloLink; + // Warning: (ae-forgotten-export) The symbol "DefaultContext" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "MutationOptions" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "MutateResult" needs to be exported by the entry point index.d.ts + mutate = DefaultContext, TCache extends ApolloCache = ApolloCache>(options: MutationOptions): Promise>>; + onClearStore(cb: () => Promise): () => void; + onResetStore(cb: () => Promise): () => void; + set prioritizeCacheValues(value: boolean); + get prioritizeCacheValues(): boolean; + // Warning: (ae-forgotten-export) The symbol "QueryOptions" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "QueryResult_2" needs to be exported by the entry point index.d.ts + query(options: QueryOptions): Promise>>; + // (undocumented) + queryDeduplication: boolean; + readFragment(options: DataProxy.Fragment, optimistic?: boolean): Unmasked | null; + readQuery(options: DataProxy.Query, optimistic?: boolean): Unmasked | null; + reFetchObservableQueries(includeStandby?: boolean): Promise[]>; + // Warning: (ae-forgotten-export) The symbol "RefetchQueriesOptions" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "RefetchQueriesResult" needs to be exported by the entry point index.d.ts + refetchQueries>>(options: RefetchQueriesOptions): RefetchQueriesResult; + resetStore(): Promise[] | null>; + restore(serializedState: unknown): ApolloCache; + setLink(newLink: ApolloLink): void; + // Warning: (ae-forgotten-export) The symbol "FragmentMatcher" needs to be exported by the entry point index.d.ts + setLocalStateFragmentMatcher(fragmentMatcher: FragmentMatcher): void; + 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-forgotten-export) The symbol "SubscribeResult" needs to be exported by the entry point index.d.ts + subscribe(options: SubscriptionOptions): Observable>>; + // Warning: (ae-forgotten-export) The symbol "ApolloClientOptions" needs to be exported by the entry point index.d.ts + // + // (undocumented) + readonly typeDefs: ApolloClientOptions["typeDefs"]; + // (undocumented) + version: string; + watchFragment(options: WatchFragmentOptions): Observable>; + // Warning: (ae-forgotten-export) The symbol "OperationVariables_2" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "WatchQueryOptions_2" 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 + watchQuery(options: WatchQueryOptions_2): ObservableQuery; + writeFragment(options: DataProxy.WriteFragmentOptions): Reference | undefined; + writeQuery(options: DataProxy.WriteQueryOptions): Reference | undefined; +} + +// @public (undocumented) +interface ApolloClientOptions { + assumeImmutableResults?: boolean; + cache: ApolloCache; + // @deprecated + connectToDevTools?: boolean; + // (undocumented) + credentials?: string; + dataMasking?: boolean; + // (undocumented) + defaultContext?: Partial; + defaultOptions?: DefaultOptions; + devtools?: DevtoolsOptions; + // (undocumented) + documentTransform?: DocumentTransform; + // (undocumented) + fragmentMatcher?: FragmentMatcher; + headers?: Record; + link?: ApolloLink; + name?: string; + queryDeduplication?: boolean; + // (undocumented) + resolvers?: Resolvers | Resolvers[]; + ssrForceFetchDelay?: number; + ssrMode?: boolean; + // (undocumented) + typeDefs?: string | string[] | DocumentNode | DocumentNode[]; + uri?: string | UriFunction; + version?: string; +} -export { ApolloContextValue } +// Warning: (ae-forgotten-export) The symbol "ApolloConsumer_2" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +export const ApolloConsumer: ReactTypes.FC; -export { ApolloProvider } +// @public (undocumented) +namespace ApolloConsumer_2 { + // (undocumented) + interface Props { + // (undocumented) + children: (client: ApolloClient) => ReactTypes.ReactNode; + } +} + +// @public (undocumented) +const ApolloConsumer: ReactTypes.FC; + +// @public (undocumented) +export interface ApolloContextValue { + // (undocumented) + [wrapperSymbol]?: HookWrappers; + // (undocumented) + client?: ApolloClient; +} + +// @public (undocumented) +export namespace ApolloProvider { + // (undocumented) + export interface Props { + // (undocumented) + children: ReactTypes.ReactNode | ReactTypes.ReactNode[] | null; + // (undocumented) + client: ApolloClient; + } +} + +// @public (undocumented) +export const ApolloProvider: ReactTypes.FC; + +// @public (undocumented) +interface ApolloQueryResult { + // (undocumented) + data: T | undefined; + // Warning: (ae-forgotten-export) The symbol "ErrorLike" needs to be exported by the entry point index.d.ts + error?: ErrorLike; + // (undocumented) + loading: boolean; + // Warning: (ae-forgotten-export) The symbol "NetworkStatus" needs to be exported by the entry point index.d.ts + // + // (undocumented) + networkStatus: NetworkStatus; + // @deprecated + partial: boolean; +} // @public @deprecated (undocumented) export type BackgroundQueryHookFetchPolicy = useBackgroundQuery.FetchPolicy; @@ -56,14 +245,109 @@ export type BackgroundQueryHookFetchPolicy = useBackgroundQuery.FetchPolicy; // @public @deprecated (undocumented) export type BackgroundQueryHookOptions = useBackgroundQuery.Options; +// @public (undocumented) +const enum CacheWriteBehavior { + // (undocumented) + FORBID = 0, + // (undocumented) + MERGE = 2, + // (undocumented) + OVERWRITE = 1 +} + // @public export function createQueryPreloader(client: ApolloClient): PreloadQueryFunction; -export { DocumentType_2 as DocumentType } +// @public (undocumented) +interface DefaultContext extends Record { +} + +// @public (undocumented) +interface DefaultOptions { + // (undocumented) + mutate?: Partial>; + // (undocumented) + query?: Partial>; + // (undocumented) + watchQuery?: Partial>; +} + +// @public (undocumented) +interface DevtoolsOptions { + enabled?: boolean; + name?: string; +} + +// @public +interface ErrorLike { + // (undocumented) + message: string; + // (undocumented) + name: string; + // (undocumented) + stack?: string; +} + +// @public +type ErrorPolicy = "none" | "ignore" | "all"; + +// @public (undocumented) +interface FetchMoreQueryOptions { + // (undocumented) + context?: DefaultContext; + query?: DocumentNode | TypedDocumentNode; + variables?: Partial; +} + +// @public +type FetchPolicy = "cache-first" | "network-only" | "cache-only" | "no-cache" | "standby"; -export { getApolloContext } +// @public (undocumented) +type FragmentMatcher = (rootValue: any, typeCondition: string, context: any) => boolean; -export { IDocumentDefinition } +// @public (undocumented) +type From = StoreObject_3 | Reference_2 | FragmentType> | string | null; + +// @public (undocumented) +export function getApolloContext(): ReactTypes.Context; + +// @public (undocumented) +interface IgnoreModifier { + // (undocumented) + [_ignoreModifier]: true; +} + +// @public (undocumented) +const _ignoreModifier: unique symbol; + +// Warning: (ae-forgotten-export) The symbol "InternalRefetchQueryDescriptor" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "RefetchQueriesIncludeShorthand" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type InternalRefetchQueriesInclude = InternalRefetchQueryDescriptor[] | RefetchQueriesIncludeShorthand; + +// Warning: (ae-forgotten-export) The symbol "InternalRefetchQueriesResult" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type InternalRefetchQueriesMap = Map, InternalRefetchQueriesResult>; + +// @public (undocumented) +interface InternalRefetchQueriesOptions extends Omit, "include"> { + // Warning: (ae-forgotten-export) The symbol "InternalRefetchQueriesInclude" needs to be exported by the entry point index.d.ts + // + // (undocumented) + include?: InternalRefetchQueriesInclude; + // (undocumented) + removeOptimistic?: string; +} + +// @public (undocumented) +type InternalRefetchQueriesResult = TResult extends boolean ? Promise> : TResult; + +// Warning: (ae-forgotten-export) The symbol "RefetchQueryDescriptor" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type InternalRefetchQueryDescriptor = RefetchQueryDescriptor | QueryOptions; // @public @deprecated (undocumented) export type LazyQueryExecFunction = useLazyQuery.ExecFunction; @@ -89,27 +373,257 @@ export type LoadableQueryHookOptions = useLoadableQuery.Options; // @public @deprecated (undocumented) export type LoadQueryFunction = useLoadableQuery.LoadQueryFunction; +// @public (undocumented) +class LocalState { + // Warning: (ae-forgotten-export) The symbol "LocalStateOptions" needs to be exported by the entry point index.d.ts + constructor({ cache, client, resolvers, fragmentMatcher, }: LocalStateOptions); + // (undocumented) + addExportedVariables(document: DocumentNode, variables?: TVars, context?: {}): Promise; + // (undocumented) + addResolvers(resolvers: Resolvers | Resolvers[]): void; + // (undocumented) + clientQuery(document: DocumentNode): DocumentNode | null; + // (undocumented) + getFragmentMatcher(): FragmentMatcher | undefined; + // (undocumented) + getResolvers(): Resolvers; + // (undocumented) + prepareContext(context?: Record): { + cache: ApolloCache; + getCacheKey(obj: StoreObject): string | undefined; + }; + // (undocumented) + runResolvers({ document, remoteResult, context, variables, onlyRunForcedResolvers, }: { + document: DocumentNode | null; + remoteResult: FetchResult; + context?: Record; + variables?: Record; + onlyRunForcedResolvers?: boolean; + }): Promise>; + // (undocumented) + serverQuery(document: DocumentNode): DocumentNode | null; + // (undocumented) + setFragmentMatcher(fragmentMatcher: FragmentMatcher): void; + // (undocumented) + setResolvers(resolvers: Resolvers | Resolvers[]): void; + // (undocumented) + shouldForceResolvers(document: ASTNode): boolean; +} + +// @public (undocumented) +type LocalStateOptions = { + cache: ApolloCache; + client?: ApolloClient_2; + resolvers?: Resolvers | Resolvers[]; + fragmentMatcher?: FragmentMatcher; +}; + +// @public (undocumented) +interface MaskFragmentOptions { + // (undocumented) + data: TData; + // (undocumented) + fragment: DocumentNode; + // (undocumented) + fragmentName?: string; +} + +// @public (undocumented) +interface MaskOperationOptions { + // (undocumented) + data: TData; + // (undocumented) + document: DocumentNode; + // Warning: (ae-forgotten-export) The symbol "WatchQueryFetchPolicy_2" needs to be exported by the entry point index.d.ts + // + // (undocumented) + fetchPolicy?: WatchQueryFetchPolicy_2; + // (undocumented) + id: string; +} + +// @public (undocumented) +interface MutateResult { + data: TData | undefined; + error?: ErrorLike; + extensions?: Record; +} + +// Warning: (ae-forgotten-export) The symbol "FetchPolicy" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +type MutationFetchPolicy = Extract; + // @public @deprecated (undocumented) -export type MutationFunctionOptions = useMutation.MutationFunctionOptions; +export type MutationFunctionOptions = useMutation.MutationFunctionOptions; // @public @deprecated (undocumented) -export type MutationHookOptions = useMutation.Options; +export type MutationHookOptions = useMutation.Options; + +// @public (undocumented) +interface MutationOptions { + awaitRefetchQueries?: boolean; + context?: TContext; + // Warning: (ae-forgotten-export) The symbol "ErrorPolicy" needs to be exported by the entry point index.d.ts + errorPolicy?: ErrorPolicy; + // Warning: (ae-forgotten-export) The symbol "MutationFetchPolicy" needs to be exported by the entry point index.d.ts + fetchPolicy?: MutationFetchPolicy; + keepRootFields?: boolean; + mutation: DocumentNode | TypedDocumentNode; + // Warning: (ae-forgotten-export) The symbol "OnQueryUpdated" needs to be exported by the entry point index.d.ts + onQueryUpdated?: OnQueryUpdated; + // Warning: (ae-forgotten-export) The symbol "IgnoreModifier" needs to be exported by the entry point index.d.ts + optimisticResponse?: Unmasked> | ((vars: TVariables, { IGNORE }: { + IGNORE: IgnoreModifier; + }) => Unmasked> | IgnoreModifier); + refetchQueries?: ((result: FetchResult>) => InternalRefetchQueriesInclude) | InternalRefetchQueriesInclude; + // Warning: (ae-forgotten-export) The symbol "MutationUpdaterFunction" needs to be exported by the entry point index.d.ts + update?: MutationUpdaterFunction; + // Warning: (ae-forgotten-export) The symbol "MutationQueryReducersMap" needs to be exported by the entry point index.d.ts + updateQueries?: MutationQueryReducersMap; + variables?: TVariables; +} + +// @public (undocumented) +type MutationQueryReducer = (previousResult: Record, options: { + mutationResult: FetchResult>; + queryName: string | undefined; + queryVariables: Record; +}) => Record; + +// @public (undocumented) +type MutationQueryReducersMap = { + [queryName: string]: MutationQueryReducer; +}; // @public @deprecated (undocumented) export type MutationResult = useMutation.Result; +// @public (undocumented) +interface MutationStoreValue { + // (undocumented) + error: Error | null; + // (undocumented) + loading: boolean; + // (undocumented) + mutation: DocumentNode; + // (undocumented) + variables: Record; +} + // @public @deprecated (undocumented) -export type MutationTuple = useMutation.ResultTuple; +export type MutationTuple = useMutation.ResultTuple; + +// @public (undocumented) +type MutationUpdaterFunction = (cache: TCache, result: Omit>, "context">, options: { + context?: TContext; + variables?: TVariables; +}) => void; + +// @public +enum NetworkStatus { + error = 8, + fetchMore = 3, + loading = 1, + poll = 6, + ready = 7, + refetch = 4, + setVariables = 2 +} + +// @public (undocumented) +interface NextFetchPolicyContext { + // (undocumented) + initialFetchPolicy: WatchQueryFetchPolicy_2; + // (undocumented) + observable: ObservableQuery; + // (undocumented) + options: WatchQueryOptions_2; + // (undocumented) + reason: "after-fetch" | "variables-changed"; +} + +// @public (undocumented) +interface ObservableAndInfo { + // (undocumented) + fromLink: boolean; + // Warning: (ae-forgotten-export) The symbol "ApolloQueryResult" needs to be exported by the entry point index.d.ts + // + // (undocumented) + observable: Observable>; +} + +// @public (undocumented) +class ObservableQuery implements Subscribable>>, InteropObservable>> { + // (undocumented) + ["@@observable"]: () => Subscribable>>; + // (undocumented) + [Symbol.observable]: () => Subscribable>>; + constructor({ queryManager, queryInfo, options, }: { + queryManager: QueryManager; + queryInfo: QueryInfo; + options: WatchQueryOptions_2; + }); + // Warning: (ae-forgotten-export) The symbol "FetchMoreQueryOptions" needs to be exported by the entry point index.d.ts + fetchMore(fetchMoreOptions: FetchMoreQueryOptions & { + updateQuery?: (previousQueryResult: Unmasked, options: { + fetchMoreResult: Unmasked; + variables: TFetchVars; + }) => Unmasked; + }): Promise>; + // (undocumented) + getCurrentResult(saveAsLastResult?: boolean): ApolloQueryResult>; + // (undocumented) + getLastError(variablesMustMatch?: boolean): ErrorLike | undefined; + // (undocumented) + getLastResult(variablesMustMatch?: boolean): ApolloQueryResult | undefined; + // (undocumented) + hasObservers(): boolean; + // (undocumented) + isDifferentFromLastResult(newResult: ApolloQueryResult, variables?: TVariables): boolean | undefined; + // (undocumented) + readonly options: WatchQueryOptions_2; + // (undocumented) + pipe: Observable>>["pipe"]; + // (undocumented) + get query(): TypedDocumentNode; + // (undocumented) + readonly queryId: string; + // (undocumented) + readonly queryName?: string; + refetch(variables?: Partial): Promise>; + reobserve(newOptions?: Partial>): Promise>>; + // @internal (undocumented) + resetDiff(): void; + // (undocumented) + resetLastResults(): void; + setVariables(variables: TVariables): Promise>; + // @internal (undocumented) + silentSetOptions(newOptions: Partial>): void; + startPolling(pollInterval: number): void; + stopPolling(): void; + // (undocumented) + subscribe: (observer: Partial>>> | ((value: ApolloQueryResult>) => void)) => Subscription; + // Warning: (ae-forgotten-export) The symbol "SubscribeToMoreOptions" needs to be exported by the entry point index.d.ts + subscribeToMore(options: SubscribeToMoreOptions): () => void; + // Warning: (ae-forgotten-export) The symbol "UpdateQueryMapFn" needs to be exported by the entry point index.d.ts + updateQuery(mapFn: UpdateQueryMapFn): void; + get variables(): TVariables | undefined; +} // @public @deprecated (undocumented) export type OnDataOptions = useSubscription.OnDataOptions; +// @public (undocumented) +type OnQueryUpdated = (observableQuery: ObservableQuery, diff: Cache_2.DiffResult, lastDiff: Cache_2.DiffResult | undefined) => boolean | TResult; + // @public @deprecated (undocumented) export type OnSubscriptionDataOptions = useSubscription.OnSubscriptionDataOptions; -export { operationName } - -export { parser } +// @public (undocumented) +type OperationVariables_2 = Record; export { PreloadedQueryRef } @@ -119,27 +633,27 @@ export type PreloadQueryFetchPolicy = Extract>(query: DocumentNode | TypedDocumentNode, ...[options]: PreloadQueryOptionsArg, TOptions>): PreloadedQueryRef | undefined : TData | undefined : TOptions["returnPartialData"] extends true ? DeepPartial : TData, TVariables>; - (query: DocumentNode | TypedDocumentNode, options: PreloadQueryOptions> & { + >(query: DocumentNode_2 | TypedDocumentNode_2, ...[options]: PreloadQueryOptionsArg, TOptions>): PreloadedQueryRef | undefined : TData | undefined : TOptions["returnPartialData"] extends true ? DeepPartial : TData, TVariables>; + (query: DocumentNode_2 | TypedDocumentNode_2, options: PreloadQueryOptions> & { returnPartialData: true; errorPolicy: "ignore" | "all"; }): PreloadedQueryRef | undefined, TVariables>; - (query: DocumentNode | TypedDocumentNode, options: PreloadQueryOptions> & { + (query: DocumentNode_2 | TypedDocumentNode_2, options: PreloadQueryOptions> & { errorPolicy: "ignore" | "all"; }): PreloadedQueryRef; - (query: DocumentNode | TypedDocumentNode, options: PreloadQueryOptions> & { + (query: DocumentNode_2 | TypedDocumentNode_2, options: PreloadQueryOptions> & { returnPartialData: true; }): PreloadedQueryRef, TVariables>; - (query: DocumentNode | TypedDocumentNode, ...[options]: PreloadQueryOptionsArg>): PreloadedQueryRef; + (query: DocumentNode_2 | TypedDocumentNode_2, ...[options]: PreloadQueryOptionsArg>): PreloadedQueryRef; } // @public (undocumented) export type PreloadQueryOptions = { - context?: DefaultContext; - errorPolicy?: ErrorPolicy; + context?: DefaultContext_2; + errorPolicy?: ErrorPolicy_2; fetchPolicy?: PreloadQueryFetchPolicy; returnPartialData?: boolean; - refetchWritePolicy?: RefetchWritePolicy; + refetchWritePolicy?: RefetchWritePolicy_2; } & VariablesOption; // @public (undocumented) @@ -154,6 +668,217 @@ options: PreloadQueryOptions> & Omit = useQuery.Options; +// @public (undocumented) +class QueryInfo { + constructor(queryManager: QueryManager, queryId?: string); + // (undocumented) + document: DocumentNode | null; + // (undocumented) + getDiff(): Cache_2.DiffResult; + // (undocumented) + init(query: { + document: DocumentNode; + variables: Record | undefined; + }): this; + // (undocumented) + lastRequestId: number; + // Warning: (ae-forgotten-export) The symbol "QueryListener" needs to be exported by the entry point index.d.ts + // + // (undocumented) + listeners: Set; + // Warning: (ae-forgotten-export) The symbol "CacheWriteBehavior" needs to be exported by the entry point index.d.ts + // + // (undocumented) + markResult(result: FetchResult, document: DocumentNode, options: Pick, cacheWriteBehavior: CacheWriteBehavior): void; + // (undocumented) + notify(): void; + // (undocumented) + readonly observableQuery: ObservableQuery | null; + // (undocumented) + readonly queryId: string; + // (undocumented) + reset(): void; + // (undocumented) + resetDiff(): void; + // (undocumented) + resetLastWrite(): void; + // (undocumented) + setDiff(diff: Cache_2.DiffResult | null): void; + // (undocumented) + setObservableQuery(oq: ObservableQuery | null): void; + // (undocumented) + stop(): void; + // (undocumented) + stopped: boolean; + // (undocumented) + variables?: Record; +} + +// @public (undocumented) +type QueryListener = (queryInfo: QueryInfo) => void; + +// @public (undocumented) +class QueryManager { + // Warning: (ae-forgotten-export) The symbol "QueryManagerOptions" needs to be exported by the entry point index.d.ts + constructor(options: QueryManagerOptions); + // (undocumented) + readonly assumeImmutableResults: boolean; + // (undocumented) + broadcastQueries(): void; + // (undocumented) + cache: ApolloCache; + // (undocumented) + clearStore(options?: Cache_2.ResetOptions): Promise; + // (undocumented) + readonly dataMasking: boolean; + // (undocumented) + readonly defaultContext: Partial; + // Warning: (ae-forgotten-export) The symbol "DefaultOptions" needs to be exported by the entry point index.d.ts + // + // (undocumented) + defaultOptions: DefaultOptions; + // (undocumented) + readonly documentTransform: DocumentTransform; + // (undocumented) + protected fetchCancelFns: Map any>; + // Warning: (ae-forgotten-export) The symbol "ObservableAndInfo" needs to be exported by the entry point index.d.ts + // + // (undocumented) + fetchObservableWithInfo(queryId: string, options: WatchQueryOptions_2, networkStatus?: NetworkStatus, query?: DocumentNode | TypedDocumentNode, emitLoadingState?: boolean): ObservableAndInfo; + // (undocumented) + fetchQuery(queryId: string, options: WatchQueryOptions_2, networkStatus?: NetworkStatus): Promise>; + // (undocumented) + generateMutationId(): string; + // (undocumented) + generateQueryId(): string; + // (undocumented) + generateRequestId(): number; + // Warning: (ae-forgotten-export) The symbol "TransformCacheEntry" needs to be exported by the entry point index.d.ts + // + // (undocumented) + getDocumentInfo(document: DocumentNode): TransformCacheEntry; + // Warning: (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts + // + // (undocumented) + getLocalState(): LocalState; + // (undocumented) + getObservableQueries(include?: InternalRefetchQueriesInclude): Map>; + // (undocumented) + protected inFlightLinkObservables: Trie<{ + observable?: Observable>; + }>; + // (undocumented) + link: ApolloLink; + // (undocumented) + markMutationOptimistic(optimisticResponse: any, mutation: { + mutationId: string; + document: DocumentNode; + variables?: TVariables; + fetchPolicy?: MutationFetchPolicy; + errorPolicy: ErrorPolicy; + context?: TContext; + updateQueries: UpdateQueries; + update?: MutationUpdaterFunction; + keepRootFields?: boolean; + }): boolean; + // (undocumented) + markMutationResult(mutation: { + mutationId: string; + result: FetchResult; + document: DocumentNode; + variables?: TVariables; + fetchPolicy?: MutationFetchPolicy; + errorPolicy: ErrorPolicy; + context?: TContext; + updateQueries: UpdateQueries; + update?: MutationUpdaterFunction; + awaitRefetchQueries?: boolean; + refetchQueries?: InternalRefetchQueriesInclude; + removeOptimistic?: string; + onQueryUpdated?: OnQueryUpdated; + keepRootFields?: boolean; + }, cache?: ApolloCache): Promise>; + // Warning: (ae-forgotten-export) The symbol "MaskFragmentOptions" needs to be exported by the entry point index.d.ts + // + // (undocumented) + maskFragment(options: MaskFragmentOptions): TData; + // Warning: (ae-forgotten-export) The symbol "MaskOperationOptions" needs to be exported by the entry point index.d.ts + // + // (undocumented) + maskOperation(options: MaskOperationOptions): MaybeMasked; + // (undocumented) + mutate, TCache extends ApolloCache>({ mutation, variables, optimisticResponse, updateQueries, refetchQueries, awaitRefetchQueries, update: updateWithProxyFn, onQueryUpdated, fetchPolicy, errorPolicy, keepRootFields, context, }: MutationOptions): Promise>>; + // (undocumented) + mutationStore?: { + [mutationId: string]: MutationStoreValue; + }; + prioritizeCacheValues: boolean; + // (undocumented) + query(options: QueryOptions, queryId?: string): Promise>>; + // (undocumented) + reFetchObservableQueries(includeStandby?: boolean): Promise[]>; + // Warning: (ae-forgotten-export) The symbol "InternalRefetchQueriesOptions" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "InternalRefetchQueriesMap" needs to be exported by the entry point index.d.ts + // + // (undocumented) + refetchQueries({ updateCache, include, optimistic, removeOptimistic, onQueryUpdated, }: InternalRefetchQueriesOptions): InternalRefetchQueriesMap; + // (undocumented) + removeQuery(queryId: string): void; + // (undocumented) + setObservableQuery(observableQuery: ObservableQuery): void; + // (undocumented) + readonly ssrMode: boolean; + // (undocumented) + startGraphQLSubscription(options: SubscriptionOptions): Observable>; + stop(): void; + // (undocumented) + stopQuery(queryId: string): void; + // (undocumented) + transform(document: DocumentNode): DocumentNode; + // (undocumented) + watchQuery(options: WatchQueryOptions_2): ObservableQuery; +} + +// @public (undocumented) +interface QueryManagerOptions { + // (undocumented) + assumeImmutableResults: boolean; + // (undocumented) + cache: ApolloCache; + // (undocumented) + clientAwareness: Record; + // (undocumented) + dataMasking: boolean; + // (undocumented) + defaultContext: Partial | undefined; + // (undocumented) + defaultOptions: DefaultOptions; + // (undocumented) + documentTransform: DocumentTransform | null | undefined; + // (undocumented) + link: ApolloLink; + // (undocumented) + localState: LocalState; + // (undocumented) + onBroadcast: undefined | (() => void); + // (undocumented) + queryDeduplication: boolean; + // (undocumented) + ssrMode: boolean; +} + +// @public +interface QueryOptions { + context?: DefaultContext; + errorPolicy?: ErrorPolicy; + fetchPolicy?: FetchPolicy; + notifyOnNetworkStatusChange?: boolean; + pollInterval?: number; + query: DocumentNode | TypedDocumentNode; + returnPartialData?: boolean; + variables?: TVariables; +} + export { QueryRef } export { QueryReference } @@ -161,13 +886,118 @@ export { QueryReference } // @public @deprecated (undocumented) export type QueryResult = useQuery.Result; -export { SkipToken } +// @public (undocumented) +interface QueryResult_2 { + data: TData | undefined; + error?: ErrorLike; +} -export { skipToken } +// @public (undocumented) +type RefetchQueriesInclude = RefetchQueryDescriptor[] | RefetchQueriesIncludeShorthand; + +// @public (undocumented) +type RefetchQueriesIncludeShorthand = "all" | "active"; + +// @public (undocumented) +interface RefetchQueriesOptions { + // (undocumented) + include?: RefetchQueriesInclude; + // (undocumented) + onQueryUpdated?: OnQueryUpdated | null; + // (undocumented) + optimistic?: boolean; + // (undocumented) + updateCache?: (cache: TCache) => void; +} + +// @public (undocumented) +type RefetchQueriesPromiseResults = IsStrictlyAny extends true ? any[] : TResult extends boolean ? QueryResult_2[] : TResult extends PromiseLike ? U[] : TResult[]; + +// Warning: (ae-forgotten-export) The symbol "RefetchQueriesPromiseResults" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +interface RefetchQueriesResult extends Promise> { + // (undocumented) + queries: ObservableQuery[]; + // (undocumented) + results: InternalRefetchQueriesResult[]; +} + +// @public (undocumented) +type RefetchQueryDescriptor = string | DocumentNode; + +// @public (undocumented) +type RefetchWritePolicy = "merge" | "overwrite"; + +// @public (undocumented) +type ResetFunction = () => void; + +// @public (undocumented) +type Resolver = (rootValue?: any, args?: any, context?: any, info?: { + field: FieldNode; + fragmentMap: FragmentMap; +}) => any; + +// @public (undocumented) +interface Resolvers { + // (undocumented) + [key: string]: { + [field: string]: Resolver; + }; +} + +// @public (undocumented) +export type SkipToken = typeof skipToken; + +// @public (undocumented) +export const skipToken: unique symbol; + +// @public (undocumented) +interface SubscribeResult { + data: TData | undefined; + error?: ErrorLike; + extensions?: Record; +} + +// @public (undocumented) +interface SubscribeToMoreOptions { + // (undocumented) + context?: DefaultContext; + // (undocumented) + document: DocumentNode | TypedDocumentNode; + // (undocumented) + onError?: (error: Error) => void; + // Warning: (ae-forgotten-export) The symbol "SubscribeToMoreUpdateQueryFn" needs to be exported by the entry point index.d.ts + // + // (undocumented) + updateQuery?: SubscribeToMoreUpdateQueryFn; + // (undocumented) + variables?: TSubscriptionVariables; +} + +// @public (undocumented) +type SubscribeToMoreUpdateQueryFn = { + ( + unsafePreviousData: Unmasked, options: UpdateQueryOptions & { + subscriptionData: { + data: Unmasked; + }; + }): Unmasked | void; +}; // @public @deprecated (undocumented) export type SubscriptionHookOptions = useSubscription.Options; +// @public (undocumented) +interface SubscriptionOptions { + context?: DefaultContext; + errorPolicy?: ErrorPolicy; + extensions?: Record; + fetchPolicy?: FetchPolicy; + query: DocumentNode | TypedDocumentNode; + variables?: TVariables; +} + // @public @deprecated (undocumented) export type SubscriptionResult = useSubscription.Result; @@ -177,14 +1007,172 @@ export type SuspenseQueryHookFetchPolicy = useSuspenseQuery.FetchPolicy; // @public @deprecated (undocumented) export type SuspenseQueryHookOptions = useSuspenseQuery.Options; -export { useApolloClient } +// @public (undocumented) +interface TransformCacheEntry { + // (undocumented) + asQuery: DocumentNode; + // (undocumented) + clientQuery: DocumentNode | null; + // (undocumented) + defaultVars: OperationVariables_2; + // (undocumented) + hasClientExports: boolean; + // (undocumented) + hasForcedResolvers: boolean; + // (undocumented) + hasNonreactiveDirective: boolean; + // (undocumented) + nonReactiveQuery: DocumentNode; + // (undocumented) + serverQuery: DocumentNode | null; +} + +// @public (undocumented) +type UpdateQueries = MutationOptions["updateQueries"]; + +// @public (undocumented) +interface UpdateQueryMapFn { + // (undocumented) + ( + unsafePreviousData: Unmasked, options: UpdateQueryOptions): Unmasked | void; +} + +// @public (undocumented) +type UpdateQueryOptions = { + variables?: TVariables; +} & ({ + complete: true; + previousData: Unmasked; +} | { + complete: false; + previousData: DeepPartial> | undefined; +}); + +// @public (undocumented) +export function useApolloClient(override?: ApolloClient): ApolloClient; + +// @public (undocumented) +export function useBackgroundQuery>(query: DocumentNode_2 | TypedDocumentNode_2, options?: useBackgroundQuery.Options> & TOptions): [ +(QueryRef | undefined : TData | undefined : TOptions["returnPartialData"] extends true ? DeepPartial : TData, TVariables> | (TOptions["skip"] extends boolean ? undefined : never)), +useBackgroundQuery.Result +]; + +// @public (undocumented) +export function useBackgroundQuery(query: DocumentNode_2 | TypedDocumentNode_2, options: useBackgroundQuery.Options> & { + returnPartialData: true; + errorPolicy: "ignore" | "all"; +}): [ +QueryRef | undefined, TVariables>, +useBackgroundQuery.Result +]; + +// @public (undocumented) +export function useBackgroundQuery(query: DocumentNode_2 | TypedDocumentNode_2, options: useBackgroundQuery.Options> & { + errorPolicy: "ignore" | "all"; +}): [ +QueryRef, +useBackgroundQuery.Result +]; -export { useBackgroundQuery } +// @public (undocumented) +export function useBackgroundQuery(query: DocumentNode_2 | TypedDocumentNode_2, options: useBackgroundQuery.Options> & { + skip: boolean; + returnPartialData: true; +}): [ +QueryRef, TVariables> | undefined, +useBackgroundQuery.Result +]; + +// @public (undocumented) +export function useBackgroundQuery(query: DocumentNode_2 | TypedDocumentNode_2, options: useBackgroundQuery.Options> & { + returnPartialData: true; +}): [ +QueryRef, TVariables>, +useBackgroundQuery.Result +]; + +// @public (undocumented) +export function useBackgroundQuery(query: DocumentNode_2 | TypedDocumentNode_2, options: useBackgroundQuery.Options> & { + skip: boolean; +}): [ +QueryRef | undefined, +useBackgroundQuery.Result +]; + +// @public (undocumented) +export function useBackgroundQuery(query: DocumentNode_2 | TypedDocumentNode_2, options?: useBackgroundQuery.Options>): [QueryRef, useBackgroundQuery.Result]; + +// @public (undocumented) +export function useBackgroundQuery(query: DocumentNode_2 | TypedDocumentNode_2, options: SkipToken): [undefined, useBackgroundQuery.Result]; + +// @public (undocumented) +export function useBackgroundQuery(query: DocumentNode_2 | TypedDocumentNode_2, options: SkipToken | (useBackgroundQuery.Options> & { + returnPartialData: true; +})): [ +QueryRef, TVariables> | undefined, +useBackgroundQuery.Result +]; + +// @public (undocumented) +export function useBackgroundQuery(query: DocumentNode_2 | TypedDocumentNode_2, options?: SkipToken | useBackgroundQuery.Options>): [ +QueryRef | undefined, +useBackgroundQuery.Result +]; + +// @public (undocumented) +export namespace useBackgroundQuery { + // (undocumented) + export type FetchPolicy = Extract; + // (undocumented) + export interface Options { + client?: ApolloClient; + context?: DefaultContext_2; + errorPolicy?: ErrorPolicy_2; + fetchPolicy?: FetchPolicy; + queryKey?: string | number | any[]; + refetchWritePolicy?: RefetchWritePolicy_2; + returnPartialData?: boolean; + // @deprecated + skip?: boolean; + variables?: TVariables; + } + // (undocumented) + export type Result = { + subscribeToMore: SubscribeToMoreFunction; + fetchMore: FetchMoreFunction; + refetch: RefetchFunction; + }; +} // @public @deprecated (undocumented) export type UseBackgroundQueryResult = useBackgroundQuery.Result; -export { useFragment } +// @public (undocumented) +export function useFragment(options: useFragment.Options): useFragment.Result; + +// @public (undocumented) +export namespace useFragment { + // (undocumented) + export interface Options { + client?: ApolloClient; + fragment: DocumentNode_2 | TypedDocumentNode_2; + fragmentName?: string; + // (undocumented) + from: StoreObject_2 | Reference | FragmentType> | string | null; + optimistic?: boolean; + variables?: NoInfer_2; + } + // (undocumented) + export type Result = { + data: MaybeMasked; + complete: true; + missing?: never; + } | { + data: DeepPartial>; + complete: false; + missing?: MissingTree; + }; +} // @public @deprecated (undocumented) export type UseFragmentOptions = useFragment.Options; @@ -192,32 +1180,332 @@ export type UseFragmentOptions = useFragment.Options = useFragment.Result; -export { useLazyQuery } +// @public +export function useLazyQuery(query: DocumentNode | TypedDocumentNode, options?: useLazyQuery.Options, NoInfer_2>): useLazyQuery.ResultTuple; -export { useLoadableQuery } +// @public (undocumented) +export namespace useLazyQuery { + // (undocumented) + export type ExecFunction = (...args: [TVariables] extends [never] ? [ + options?: useLazyQuery.ExecOptions + ] : Record extends OnlyRequiredProperties ? [ + options?: useLazyQuery.ExecOptions + ] : [options: useLazyQuery.ExecOptions]) => Promise>; + // (undocumented) + export type ExecOptions = { + context?: DefaultContext_2; + } & VariablesOption; + // (undocumented) + export interface Options { + client?: ApolloClient; + context?: DefaultContext_2; + errorPolicy?: ErrorPolicy_2; + fetchPolicy?: WatchQueryFetchPolicy; + // Warning: (ae-forgotten-export) The symbol "NextFetchPolicyContext" needs to be exported by the entry point index.d.ts + nextFetchPolicy?: WatchQueryFetchPolicy | ((this: WatchQueryOptions, currentFetchPolicy: WatchQueryFetchPolicy, context: NextFetchPolicyContext) => WatchQueryFetchPolicy); + notifyOnNetworkStatusChange?: boolean; + pollInterval?: number; + refetchWritePolicy?: RefetchWritePolicy_2; + returnPartialData?: boolean; + skipPollAttempt?: () => boolean; + } + // (undocumented) + export interface Result { + called: boolean; + client: ApolloClient; + data: MaybeMasked_2 | undefined; + error?: ErrorLike_2; + fetchMore: (fetchMoreOptions: FetchMoreQueryOptions_2 & { + updateQuery?: (previousQueryResult: Unmasked_2, options: { + fetchMoreResult: Unmasked_2; + variables: TFetchVars; + }) => Unmasked_2; + }) => Promise>>; + loading: boolean; + networkStatus: NetworkStatus_2; + observable: ObservableQuery_2; + previousData?: MaybeMasked_2; + refetch: (variables?: Partial) => Promise>>; + startPolling: (pollInterval: number) => void; + stopPolling: () => void; + subscribeToMore: SubscribeToMoreFunction; + updateQuery: (mapFn: UpdateQueryMapFn_2) => void; + variables: TVariables | undefined; + } + // (undocumented) + export type ResultTuple = [ + execute: ExecFunction, + result: useLazyQuery.Result + ]; +} + +// @public (undocumented) +export function useLoadableQuery(query: DocumentNode_2 | TypedDocumentNode_2, options?: useLoadableQuery.Options & TOptions): useLoadableQuery.Result | undefined : TData | undefined : TOptions["returnPartialData"] extends true ? DeepPartial : TData, TVariables>; + +// @public (undocumented) +export function useLoadableQuery(query: DocumentNode_2 | TypedDocumentNode_2, options: useLoadableQuery.Options & { + returnPartialData: true; + errorPolicy: "ignore" | "all"; +}): useLoadableQuery.Result | undefined, TVariables>; + +// @public (undocumented) +export function useLoadableQuery(query: DocumentNode_2 | TypedDocumentNode_2, options: useLoadableQuery.Options & { + errorPolicy: "ignore" | "all"; +}): useLoadableQuery.Result; + +// @public (undocumented) +export function useLoadableQuery(query: DocumentNode_2 | TypedDocumentNode_2, options: useLoadableQuery.Options & { + returnPartialData: true; +}): useLoadableQuery.Result, TVariables>; + +// @public +export function useLoadableQuery(query: DocumentNode_2 | TypedDocumentNode_2, options?: useLoadableQuery.Options): useLoadableQuery.Result; + +// @public (undocumented) +export namespace useLoadableQuery { + // (undocumented) + export type FetchPolicy = Extract; + // (undocumented) + export type LoadQueryFunction = (...args: [TVariables] extends [never] ? [] : {} extends OnlyRequiredProperties ? [variables?: TVariables] : [variables: TVariables]) => void; + // (undocumented) + export interface Options { + client?: ApolloClient; + context?: DefaultContext_2; + errorPolicy?: ErrorPolicy_2; + fetchPolicy?: FetchPolicy; + queryKey?: string | number | any[]; + refetchWritePolicy?: RefetchWritePolicy_2; + returnPartialData?: boolean; + } + // (undocumented) + export type Result = [ + loadQuery: LoadQueryFunction, + queryRef: QueryRef | null, + handlers: { + fetchMore: FetchMoreFunction; + refetch: RefetchFunction; + subscribeToMore: SubscribeToMoreFunction; + reset: ResetFunction; + } + ]; +} // @public @deprecated (undocumented) export type UseLoadableQueryResult = useLoadableQuery.Result; -export { useMutation } +// @public +export function useMutation(mutation: DocumentNode_2 | TypedDocumentNode, options?: useMutation.Options, NoInfer_2, TContext, TCache>): useMutation.ResultTuple; -export { useQuery } +// @public (undocumented) +export namespace useMutation { + // (undocumented) + export interface MutationFunctionOptions extends Options { + mutation?: DocumentNode_2 | TypedDocumentNode; + } + // (undocumented) + export interface Options { + awaitRefetchQueries?: boolean; + client?: ApolloClient; + context?: TContext; + errorPolicy?: ErrorPolicy_2; + fetchPolicy?: MutationFetchPolicy_2; + keepRootFields?: boolean; + notifyOnNetworkStatusChange?: boolean; + onCompleted?: (data: MaybeMasked_2, clientOptions?: Options) => void; + onError?: (error: ErrorLike_2, clientOptions?: Options) => void; + onQueryUpdated?: OnQueryUpdated_2; + optimisticResponse?: Unmasked_2> | ((vars: TVariables, { IGNORE }: { + IGNORE: IgnoreModifier; + }) => Unmasked_2> | IgnoreModifier); + refetchQueries?: ((result: FetchResult_2>) => InternalRefetchQueriesInclude_2) | InternalRefetchQueriesInclude_2; + update?: MutationUpdaterFunction_2; + updateQueries?: MutationQueryReducersMap_2; + variables?: TVariables; + } + // (undocumented) + export interface Result { + called: boolean; + client: ApolloClient; + data: MaybeMasked_2 | null | undefined; + error: ErrorLike_2 | undefined; + loading: boolean; + reset: () => void; + } + // (undocumented) + export type ResultTuple = [ + mutate: (options?: MutationFunctionOptions) => Promise>>, + result: Result + ]; +} -export { useQueryRefHandlers } +// @public +export function useQuery(query: DocumentNode_2 | TypedDocumentNode_2, options?: useQuery.Options, NoInfer_2>): useQuery.Result; + +// @public (undocumented) +export namespace useQuery { + // (undocumented) + export interface Options { + client?: ApolloClient; + context?: DefaultContext_2; + errorPolicy?: ErrorPolicy_2; + fetchPolicy?: WatchQueryFetchPolicy; + initialFetchPolicy?: WatchQueryFetchPolicy; + nextFetchPolicy?: WatchQueryFetchPolicy | ((this: WatchQueryOptions, currentFetchPolicy: WatchQueryFetchPolicy, context: NextFetchPolicyContext) => WatchQueryFetchPolicy); + notifyOnNetworkStatusChange?: boolean; + pollInterval?: number; + refetchWritePolicy?: RefetchWritePolicy_2; + returnPartialData?: boolean; + skip?: boolean; + skipPollAttempt?: () => boolean; + ssr?: boolean; + variables?: TVariables; + } + // (undocumented) + export interface Result { + client: ApolloClient; + data: MaybeMasked | undefined; + error?: ErrorLike_2; + fetchMore: (fetchMoreOptions: FetchMoreQueryOptions_2 & { + updateQuery?: (previousQueryResult: Unmasked, options: { + fetchMoreResult: Unmasked; + variables: TFetchVars; + }) => Unmasked; + }) => Promise>>; + loading: boolean; + networkStatus: NetworkStatus_2; + observable: ObservableQuery_2; + previousData?: MaybeMasked; + refetch: (variables?: Partial) => Promise>>; + startPolling: (pollInterval: number) => void; + stopPolling: () => void; + subscribeToMore: SubscribeToMoreFunction; + updateQuery: (mapFn: UpdateQueryMapFn_2) => void; + variables: TVariables | undefined; + } +} + +// @public (undocumented) +export namespace useQuery { + var // (undocumented) + ssrDisabledResult: ApolloQueryResult_2; + var // (undocumented) + skipStandbyResult: ApolloQueryResult_2; +} + +// @public +export function useQueryRefHandlers(queryRef: QueryRef): useQueryRefHandlers.Result; + +// @public (undocumented) +export namespace useQueryRefHandlers { + // (undocumented) + export interface Result { + fetchMore: FetchMoreFunction; + refetch: RefetchFunction; + subscribeToMore: SubscribeToMoreFunction; + } +} // @public @deprecated (undocumented) export type UseQueryRefHandlersResult = useQueryRefHandlers.Result; -export { useReactiveVar } +// @public +export function useReactiveVar(rv: ReactiveVar): T; + +// @public (undocumented) +export function useReadQuery(queryRef: QueryRef): useReadQuery.Result; -export { useReadQuery } +// @public (undocumented) +export namespace useReadQuery { + // (undocumented) + export interface Result { + data: MaybeMasked; + error: ErrorLike_2 | undefined; + networkStatus: NetworkStatus_2; + } +} // @public @deprecated (undocumented) export type UseReadQueryResult = useReadQuery.Result; -export { useSubscription } +// @public +export function useSubscription(subscription: DocumentNode | TypedDocumentNode, options?: useSubscription.Options, NoInfer_2>): useSubscription.Result; -export { useSuspenseFragment } +// @public (undocumented) +export namespace useSubscription { + // (undocumented) + export interface OnDataOptions { + // (undocumented) + client: ApolloClient; + // (undocumented) + data: OnDataResult; + } + // (undocumented) + export type OnDataResult = Omit, "restart">; + // (undocumented) + export interface OnSubscriptionDataOptions { + // (undocumented) + client: ApolloClient; + // (undocumented) + subscriptionData: OnDataResult; + } + // (undocumented) + export interface Options { + client?: ApolloClient; + context?: DefaultContext_2; + errorPolicy?: ErrorPolicy_2; + extensions?: Record; + fetchPolicy?: FetchPolicy_2; + ignoreResults?: boolean; + onComplete?: () => void; + onData?: (options: OnDataOptions) => any; + onError?: (error: ErrorLike_2) => void; + shouldResubscribe?: boolean | ((options: Options) => boolean); + skip?: boolean; + variables?: TVariables; + } + // (undocumented) + export interface Result { + data?: MaybeMasked; + error?: ErrorLike_2; + loading: boolean; + // (undocumented) + restart: () => void; + } +} + +// @public (undocumented) +export function useSuspenseFragment(options: useSuspenseFragment.Options & { + from: NonNullable>; +}): useSuspenseFragment.Result; + +// @public (undocumented) +export function useSuspenseFragment(options: useSuspenseFragment.Options & { + from: null; +}): useSuspenseFragment.Result; + +// @public (undocumented) +export function useSuspenseFragment(options: useSuspenseFragment.Options & { + from: From; +}): useSuspenseFragment.Result; + +// @public (undocumented) +export function useSuspenseFragment(options: useSuspenseFragment.Options): useSuspenseFragment.Result; + +// @public (undocumented) +export namespace useSuspenseFragment { + // (undocumented) + export type Options = { + fragment: DocumentNode_2 | TypedDocumentNode_2; + fragmentName?: string; + from: From; + optimistic?: boolean; + client?: ApolloClient; + } & VariablesOption>; + // (undocumented) + export type Result = { + data: MaybeMasked; + }; +} // @public @deprecated (undocumented) export type UseSuspenseFragmentOptions = useSuspenseFragment.Options; @@ -225,11 +1513,112 @@ export type UseSuspenseFragmentOptions = useSuspenseFragment.Result; -export { useSuspenseQuery } +// @public (undocumented) +export function useSuspenseQuery>(query: DocumentNode_2 | TypedDocumentNode_2, options?: useSuspenseQuery.Options> & TOptions): useSuspenseQuery.Result | undefined : TData | undefined : TOptions["returnPartialData"] extends true ? TOptions["skip"] extends boolean ? DeepPartial | undefined : DeepPartial : TOptions["skip"] extends boolean ? TData | undefined : TData, TVariables>; + +// @public (undocumented) +export function useSuspenseQuery(query: DocumentNode_2 | TypedDocumentNode_2, options: useSuspenseQuery.Options> & { + returnPartialData: true; + errorPolicy: "ignore" | "all"; +}): useSuspenseQuery.Result | undefined, TVariables>; + +// @public (undocumented) +export function useSuspenseQuery(query: DocumentNode_2 | TypedDocumentNode_2, options: useSuspenseQuery.Options> & { + errorPolicy: "ignore" | "all"; +}): useSuspenseQuery.Result; + +// @public (undocumented) +export function useSuspenseQuery(query: DocumentNode_2 | TypedDocumentNode_2, options: useSuspenseQuery.Options> & { + skip: boolean; + returnPartialData: true; +}): useSuspenseQuery.Result | undefined, TVariables>; + +// @public (undocumented) +export function useSuspenseQuery(query: DocumentNode_2 | TypedDocumentNode_2, options: useSuspenseQuery.Options> & { + returnPartialData: true; +}): useSuspenseQuery.Result, TVariables>; + +// @public (undocumented) +export function useSuspenseQuery(query: DocumentNode_2 | TypedDocumentNode_2, options: useSuspenseQuery.Options> & { + skip: boolean; +}): useSuspenseQuery.Result; + +// @public (undocumented) +export function useSuspenseQuery(query: DocumentNode_2 | TypedDocumentNode_2, options?: useSuspenseQuery.Options>): useSuspenseQuery.Result; + +// @public (undocumented) +export function useSuspenseQuery(query: DocumentNode_2 | TypedDocumentNode_2, options: SkipToken | (useSuspenseQuery.Options> & { + returnPartialData: true; +})): useSuspenseQuery.Result | undefined, TVariables>; + +// @public (undocumented) +export function useSuspenseQuery(query: DocumentNode_2 | TypedDocumentNode_2, options?: SkipToken | useSuspenseQuery.Options>): useSuspenseQuery.Result; + +// @public (undocumented) +export namespace useSuspenseQuery { + // (undocumented) + export type FetchPolicy = Extract; + // (undocumented) + export interface Options { + client?: ApolloClient; + context?: DefaultContext_2; + errorPolicy?: ErrorPolicy_2; + fetchPolicy?: FetchPolicy; + queryKey?: string | number | any[]; + refetchWritePolicy?: RefetchWritePolicy_2; + returnPartialData?: boolean; + // @deprecated + skip?: boolean; + variables?: TVariables; + } + // (undocumented) + export interface Result { + client: ApolloClient; + data: MaybeMasked; + error: ErrorLike_2 | undefined; + fetchMore: FetchMoreFunction; + networkStatus: NetworkStatus_2; + refetch: RefetchFunction; + subscribeToMore: SubscribeToMoreFunction; + } +} // @public @deprecated (undocumented) export type UseSuspenseQueryResult = useSuspenseQuery.Result; +// @public (undocumented) +type WatchQueryFetchPolicy_2 = FetchPolicy | "cache-and-network"; + +// @public +interface WatchQueryOptions_2 { + context?: DefaultContext; + errorPolicy?: ErrorPolicy; + fetchPolicy?: WatchQueryFetchPolicy_2; + initialFetchPolicy?: WatchQueryFetchPolicy_2; + nextFetchPolicy?: WatchQueryFetchPolicy_2 | ((this: WatchQueryOptions_2, currentFetchPolicy: WatchQueryFetchPolicy_2, context: NextFetchPolicyContext) => WatchQueryFetchPolicy_2); + notifyOnNetworkStatusChange?: boolean; + pollInterval?: number; + query: DocumentNode | TypedDocumentNode; + // Warning: (ae-forgotten-export) The symbol "RefetchWritePolicy" needs to be exported by the entry point index.d.ts + refetchWritePolicy?: RefetchWritePolicy; + returnPartialData?: boolean; + skipPollAttempt?: () => boolean; + variables?: TVariables; +} + +// Warnings were encountered during analysis: +// +// src/core/LocalState.ts:71:3 - (ae-forgotten-export) The symbol "ApolloClient_2" needs to be exported by the entry point index.d.ts +// src/core/ObservableQuery.ts:130:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts +// src/core/ObservableQuery.ts:131:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts +// src/core/QueryManager.ts:185:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts +// src/core/QueryManager.ts:455:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts +// src/core/types.ts:204:3 - (ae-forgotten-export) The symbol "MutationQueryReducer" needs to be exported by the entry point index.d.ts +// src/core/types.ts:233:5 - (ae-forgotten-export) The symbol "Resolver" needs to be exported by the entry point index.d.ts +// src/core/watchQueryOptions.ts:195:3 - (ae-forgotten-export) The symbol "UpdateQueryOptions" needs to be exported by the entry point index.d.ts +// src/react/hooks/useLoadableQuery.ts:72:7 - (ae-forgotten-export) The symbol "ResetFunction" needs to be exported by the entry point index.d.ts +// src/react/hooks/useSuspenseFragment.ts:73:5 - (ae-forgotten-export) The symbol "From" needs to be exported by the entry point index.d.ts + // (No @packageDocumentation comment for this package) ``` diff --git a/.api-reports/api-report-react_internal.api.md b/.api-reports/api-report-react_internal.api.md index b0e8643c2ac..97d27f86dd7 100644 --- a/.api-reports/api-report-react_internal.api.md +++ b/.api-reports/api-report-react_internal.api.md @@ -18,13 +18,13 @@ import type { OperationVariables } from '@apollo/client/core'; import type { PromiseWithState } from '@apollo/client/utilities'; import type { QueryResult } from '@apollo/client/core'; import type { Unmasked } from '@apollo/client/core'; -import type { useBackgroundQuery } from '@apollo/client/react/hooks'; -import type { useFragment } from '@apollo/client/react/hooks'; -import type { useQuery } from '@apollo/client/react/hooks'; -import type { useQueryRefHandlers } from '@apollo/client/react/hooks'; -import type { useReadQuery } from '@apollo/client/react/hooks'; -import type { useSuspenseFragment } from '@apollo/client/react/hooks'; -import type { useSuspenseQuery } from '@apollo/client/react/hooks'; +import type { useBackgroundQuery } from '@apollo/client/react'; +import type { useFragment } from '@apollo/client/react'; +import type { useQuery } from '@apollo/client/react'; +import type { useQueryRefHandlers } from '@apollo/client/react'; +import type { useReadQuery } from '@apollo/client/react'; +import type { useSuspenseFragment } from '@apollo/client/react'; +import type { useSuspenseQuery } from '@apollo/client/react'; import type { WatchFragmentOptions } from '@apollo/client/core'; import type { WatchFragmentOptions as WatchFragmentOptions_2 } from '@apollo/client/cache'; import type { WatchFragmentResult } from '@apollo/client/cache'; diff --git a/.api-reports/api-report-utilities.api.md b/.api-reports/api-report-utilities.api.md index adef22ae240..157f6777fa3 100644 --- a/.api-reports/api-report-utilities.api.md +++ b/.api-reports/api-report-utilities.api.md @@ -25,6 +25,7 @@ import type { MutationOptions } from '@apollo/client/core'; import type { NameNode } from 'graphql'; import { Observable } from 'rxjs'; import type { OperationDefinitionNode } from 'graphql'; +import type { OperationTypeNode } from 'graphql'; import type { OperationVariables } from '@apollo/client/core'; import type { QueryOptions } from '@apollo/client/core'; import type { Reference as Reference_2 } from '@apollo/client/cache'; @@ -84,7 +85,6 @@ export interface CacheSizes { "queryManager.getDocumentInfo": number; "removeTypenameFromVariables.getVariableDefinitions": number; canonicalStringify: number; - parser: number; print: number; } @@ -103,7 +103,7 @@ export const canUseDOM: boolean; export const canUseLayoutEffect: boolean; // @public (undocumented) -export function checkDocument(doc: DocumentNode): DocumentNode; +export function checkDocument(doc: DocumentNode, expectedType?: OperationTypeNode): DocumentNode; // @public export function cloneDeep(value: T): T; @@ -213,8 +213,6 @@ export const enum defaultCacheSizes { // (undocumented) canonicalStringify = 1000, // (undocumented) - parser = 1000, - // (undocumented) print = 2000 } diff --git a/.api-reports/api-report-utilities_internal.api.md b/.api-reports/api-report-utilities_internal.api.md index 724464109e8..e7f61213a09 100644 --- a/.api-reports/api-report-utilities_internal.api.md +++ b/.api-reports/api-report-utilities_internal.api.md @@ -38,7 +38,6 @@ export const getApolloClientMemoryInternals: (() => { transform: number | undefined; } | undefined; print: number | undefined; - parser: number | undefined; canonicalStringify: number | undefined; links: unknown[]; queryManager: { diff --git a/.api-reports/api-report.api.md b/.api-reports/api-report.api.md index c0825bc0dc6..82b25bdef39 100644 --- a/.api-reports/api-report.api.md +++ b/.api-reports/api-report.api.md @@ -962,7 +962,6 @@ const getApolloClientMemoryInternals: (() => { transform: number | undefined; } | undefined; print: number | undefined; - parser: number | undefined; canonicalStringify: number | undefined; links: unknown[]; queryManager: { @@ -2482,7 +2481,7 @@ interface WriteContext extends ReadMergeModifyContext { // src/cache/inmemory/types.ts:133:3 - (ae-forgotten-export) The symbol "KeyFieldsFunction" needs to be exported by the entry point index.d.ts // src/core/ObservableQuery.ts:130:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts // src/core/ObservableQuery.ts:131:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts -// src/core/QueryManager.ts:187:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts +// src/core/QueryManager.ts:185:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts // src/core/QueryManager.ts:455:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts // src/link/http/selectHttpOptionsAndBody.ts:128:1 - (ae-forgotten-export) The symbol "HttpQueryOptions" needs to be exported by the entry point index.d.ts diff --git a/.changeset/dirty-eagles-poke.md b/.changeset/dirty-eagles-poke.md new file mode 100644 index 00000000000..882c28f828b --- /dev/null +++ b/.changeset/dirty-eagles-poke.md @@ -0,0 +1,5 @@ +--- +"@apollo/client": major +--- + +Removed the `@apollo/client/react/context` and `@apollo/client/react/hooks` entry points. Please use `@apollo/client/react` instead. diff --git a/.changeset/nice-dots-matter.md b/.changeset/nice-dots-matter.md new file mode 100644 index 00000000000..961b22a03c9 --- /dev/null +++ b/.changeset/nice-dots-matter.md @@ -0,0 +1,5 @@ +--- +"@apollo/client": patch +--- + +Removed the `parser` cache. The functionality has been replaced in a way that doesn't need caching. diff --git a/.changeset/purple-bears-flash.md b/.changeset/purple-bears-flash.md new file mode 100644 index 00000000000..36e0e07f5d5 --- /dev/null +++ b/.changeset/purple-bears-flash.md @@ -0,0 +1,5 @@ +--- +"@apollo/client": major +--- + +Removed the `@apollo/client/react/parser` entry point. There is no replacement. diff --git a/.size-limits.json b/.size-limits.json index 0f9cf383a72..9db643f4ae9 100644 --- a/.size-limits.json +++ b/.size-limits.json @@ -1,6 +1,6 @@ { - "import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (CJS)": 42953, - "import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production) (CJS)": 38324, - "import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\"": 32954, - "import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production)": 27724 + "import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (CJS)": 42819, + "import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production) (CJS)": 38357, + "import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\"": 32736, + "import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production)": 27747 } diff --git a/package.json b/package.json index aff6fc00fe5..7da8766102a 100644 --- a/package.json +++ b/package.json @@ -53,10 +53,7 @@ "react-server": "./src/react/index.react-server.ts", "default": "./src/react/index.ts" }, - "./react/context": "./src/react/context/index.ts", - "./react/hooks": "./src/react/hooks/index.ts", "./react/internal": "./src/react/internal/index.ts", - "./react/parser": "./src/react/parser/index.ts", "./react/ssr": "./src/react/ssr/index.ts", "./testing": "./src/testing/index.ts", "./testing/core": "./src/testing/core/index.ts", diff --git a/src/__tests__/__snapshots__/exports.ts.snap b/src/__tests__/__snapshots__/exports.ts.snap index a70879b2e68..3d636784279 100644 --- a/src/__tests__/__snapshots__/exports.ts.snap +++ b/src/__tests__/__snapshots__/exports.ts.snap @@ -248,11 +248,8 @@ exports[`exports of public entry points @apollo/client/react 1`] = ` Array [ "ApolloConsumer", "ApolloProvider", - "DocumentType", "createQueryPreloader", "getApolloContext", - "operationName", - "parser", "skipToken", "useApolloClient", "useBackgroundQuery", @@ -274,38 +271,8 @@ exports[`exports of public entry points @apollo/client/react with conditions [re Array [ "ApolloConsumer", "ApolloProvider", - "DocumentType", "createQueryPreloader", "getApolloContext", - "operationName", - "parser", - "useApolloClient", - "useBackgroundQuery", - "useFragment", - "useLazyQuery", - "useLoadableQuery", - "useMutation", - "useQuery", - "useQueryRefHandlers", - "useReactiveVar", - "useReadQuery", - "useSubscription", - "useSuspenseFragment", - "useSuspenseQuery", -] -`; - -exports[`exports of public entry points @apollo/client/react/context 1`] = ` -Array [ - "ApolloConsumer", - "ApolloProvider", - "getApolloContext", -] -`; - -exports[`exports of public entry points @apollo/client/react/hooks 1`] = ` -Array [ - "skipToken", "useApolloClient", "useBackgroundQuery", "useFragment", @@ -335,15 +302,6 @@ Array [ ] `; -exports[`exports of public entry points @apollo/client/react/parser 1`] = ` -Array [ - "DocumentType", - "operationName", - "parser", - "verifyDocumentType", -] -`; - exports[`exports of public entry points @apollo/client/react/ssr 1`] = ` Array [ "getDataFromTree", diff --git a/src/__tests__/exports.ts b/src/__tests__/exports.ts index 4e8105f75bb..518920214a1 100644 --- a/src/__tests__/exports.ts +++ b/src/__tests__/exports.ts @@ -27,10 +27,7 @@ import * as linkUtils from "@apollo/client/link/utils"; import * as linkWS from "@apollo/client/link/ws"; import * as masking from "@apollo/client/masking"; import * as react from "@apollo/client/react"; -import * as reactContext from "@apollo/client/react/context"; -import * as reactHooks from "@apollo/client/react/hooks"; import * as reactInternal from "@apollo/client/react/internal"; -import * as reactParser from "@apollo/client/react/parser"; import * as reactSSR from "@apollo/client/react/ssr"; import * as testing from "@apollo/client/testing"; import * as testingCore from "@apollo/client/testing/core"; @@ -90,10 +87,7 @@ describe("exports of public entry points", () => { check("@apollo/client/link/ws", linkWS); check("@apollo/client/masking", masking); check("@apollo/client/react", react); - check("@apollo/client/react/context", reactContext); - check("@apollo/client/react/hooks", reactHooks); check("@apollo/client/react/internal", reactInternal); - check("@apollo/client/react/parser", reactParser); check("@apollo/client/react/ssr", reactSSR); check("@apollo/client/testing", testing); check("@apollo/client/testing/core", testingCore); diff --git a/src/core/ApolloClient.ts b/src/core/ApolloClient.ts index 8d74e893fe3..9f13c27fbf8 100644 --- a/src/core/ApolloClient.ts +++ b/src/core/ApolloClient.ts @@ -891,7 +891,6 @@ export class ApolloClient implements DataProxy { * ```json *{ * limits: { - * parser: 1000, * canonicalStringify: 1000, * print: 2000, * 'documentTransform.cache': 2000, @@ -907,7 +906,6 @@ export class ApolloClient implements DataProxy { * 'inMemoryCache.executeSubSelectedArray': 5000 * }, * sizes: { - * parser: 26, * canonicalStringify: 4, * print: 14, * addTypenameDocumentTransform: [ diff --git a/src/core/QueryManager.ts b/src/core/QueryManager.ts index 53cec3c6b5f..052f10b656b 100644 --- a/src/core/QueryManager.ts +++ b/src/core/QueryManager.ts @@ -1,5 +1,6 @@ import { Trie } from "@wry/trie"; import type { DocumentNode } from "graphql"; +import { OperationTypeNode } from "graphql"; import type { Subscription } from "rxjs"; import { catchError, @@ -32,7 +33,7 @@ import { execute } from "@apollo/client/link/core"; import type { MaybeMasked, Unmasked } from "@apollo/client/masking"; import { maskFragment, maskOperation } from "@apollo/client/masking"; import type { DeepPartial } from "@apollo/client/utilities"; -import { print } from "@apollo/client/utilities"; +import { checkDocument, print } from "@apollo/client/utilities"; import { AutoCleanedWeakCache, cacheSizes } from "@apollo/client/utilities"; import { addNonReactiveToNamedFragments, @@ -102,9 +103,6 @@ import type { const { hasOwnProperty } = Object.prototype; -// TODO(brian): A hack until this issue is resolved (https://github.com/graphql/graphql-js/issues/3356) -type OperationTypeNode = any; - const IGNORE = {} as IgnoreModifier; interface MutationStoreValue { @@ -276,6 +274,8 @@ export class QueryManager { "mutation option is required. You must specify your GraphQL document in the mutation option." ); + checkDocument(mutation, OperationTypeNode.MUTATION); + invariant( fetchPolicy === "network-only" || fetchPolicy === "no-cache", "Mutations support only 'network-only' or 'no-cache' fetchPolicy strings. The default `network-only` behavior automatically writes mutation results to the cache. Passing `no-cache` skips the cache write." @@ -788,6 +788,8 @@ export class QueryManager { T, TVariables extends OperationVariables = OperationVariables, >(options: WatchQueryOptions): ObservableQuery { + checkDocument(options.query, OperationTypeNode.QUERY); + const query = this.transform(options.query); // assign variable default values if supplied @@ -824,6 +826,8 @@ export class QueryManager { options: QueryOptions, queryId = this.generateQueryId() ): Promise>> { + checkDocument(options.query, OperationTypeNode.QUERY); + const query = this.transform(options.query); return this.fetchQuery(queryId, { ...options, query }) @@ -1027,6 +1031,8 @@ export class QueryManager { extensions = {}, } = options; + checkDocument(query, OperationTypeNode.SUBSCRIPTION); + query = this.transform(query); variables = this.getVariables(query, variables); diff --git a/src/link/persisted-queries/__tests__/react.test.tsx b/src/link/persisted-queries/__tests__/react.test.tsx index bb173e3f314..2c2975ecedb 100644 --- a/src/link/persisted-queries/__tests__/react.test.tsx +++ b/src/link/persisted-queries/__tests__/react.test.tsx @@ -15,8 +15,7 @@ import { createPersistedQueryLink as createPersistedQuery, VERSION, } from "@apollo/client/link/persisted-queries"; -import { useQuery } from "@apollo/client/react"; -import { ApolloProvider } from "@apollo/client/react/context"; +import { ApolloProvider, useQuery } from "@apollo/client/react"; import { getDataFromTree } from "@apollo/client/react/ssr"; import { addTypenameToDocument } from "@apollo/client/utilities"; diff --git a/src/react/context/ApolloConsumer.tsx b/src/react/context/ApolloConsumer.tsx index 4a33711c89c..c371a73625c 100644 --- a/src/react/context/ApolloConsumer.tsx +++ b/src/react/context/ApolloConsumer.tsx @@ -6,11 +6,13 @@ import { invariant } from "@apollo/client/utilities/invariant"; import { getApolloContext } from "./ApolloContext.js"; -export interface ApolloConsumerProps { - children: (client: ApolloClient) => ReactTypes.ReactNode; +declare namespace ApolloConsumer { + export interface Props { + children: (client: ApolloClient) => ReactTypes.ReactNode; + } } -export const ApolloConsumer: ReactTypes.FC = (props) => { +export const ApolloConsumer: ReactTypes.FC = (props) => { const ApolloContext = getApolloContext(); return ( diff --git a/src/react/context/ApolloProvider.tsx b/src/react/context/ApolloProvider.tsx index 74b028e9ab1..385c0c81a38 100644 --- a/src/react/context/ApolloProvider.tsx +++ b/src/react/context/ApolloProvider.tsx @@ -6,12 +6,14 @@ import { invariant } from "@apollo/client/utilities/invariant"; import { getApolloContext } from "./ApolloContext.js"; -export interface ApolloProviderProps { - client: ApolloClient; - children: ReactTypes.ReactNode | ReactTypes.ReactNode[] | null; +export declare namespace ApolloProvider { + interface Props { + client: ApolloClient; + children: ReactTypes.ReactNode | ReactTypes.ReactNode[] | null; + } } -export const ApolloProvider: ReactTypes.FC = ({ +export const ApolloProvider: ReactTypes.FC = ({ client, children, }) => { diff --git a/src/react/context/__tests__/ApolloConsumer.test.tsx b/src/react/context/__tests__/ApolloConsumer.test.tsx index d2a67643ba5..86f02b7e9df 100644 --- a/src/react/context/__tests__/ApolloConsumer.test.tsx +++ b/src/react/context/__tests__/ApolloConsumer.test.tsx @@ -8,7 +8,7 @@ import { ApolloConsumer, ApolloProvider, getApolloContext, -} from "@apollo/client/react/context"; +} from "@apollo/client/react"; const client = new ApolloClient({ cache: new Cache(), diff --git a/src/react/context/__tests__/ApolloProvider.test.tsx b/src/react/context/__tests__/ApolloProvider.test.tsx index 002529a724e..7ab1dbdb2ed 100644 --- a/src/react/context/__tests__/ApolloProvider.test.tsx +++ b/src/react/context/__tests__/ApolloProvider.test.tsx @@ -4,10 +4,9 @@ import React, { useContext } from "react"; import { InMemoryCache as Cache } from "@apollo/client/cache"; import { ApolloClient } from "@apollo/client/core"; import { ApolloLink } from "@apollo/client/link/core"; -import { ApolloProvider, getApolloContext } from "@apollo/client/react/context"; +import { ApolloProvider, getApolloContext } from "@apollo/client/react"; import type { ApolloContextValue } from "../ApolloContext.js"; -import type { ApolloProviderProps } from "../ApolloProvider.js"; describe(" Component", () => { const client = new ApolloClient({ @@ -115,8 +114,8 @@ describe(" Component", () => { describe.each< [ string, - Omit, - Omit, + Omit, + Omit, ] >([["client", { client }, { client: anotherClient }]])( "context value stability, %s prop", diff --git a/src/react/context/index.ts b/src/react/context/index.ts deleted file mode 100644 index 373dac28bb8..00000000000 --- a/src/react/context/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type { ApolloConsumerProps } from "./ApolloConsumer.js"; -export { ApolloConsumer } from "./ApolloConsumer.js"; -export type { ApolloContextValue } from "./ApolloContext.js"; -export { getApolloContext } from "./ApolloContext.js"; -export type { ApolloProviderProps } from "./ApolloProvider.js"; -export { ApolloProvider } from "./ApolloProvider.js"; diff --git a/src/react/hooks/__tests__/useApolloClient.test.tsx b/src/react/hooks/__tests__/useApolloClient.test.tsx index fd5dd662525..e1562aa02ff 100644 --- a/src/react/hooks/__tests__/useApolloClient.test.tsx +++ b/src/react/hooks/__tests__/useApolloClient.test.tsx @@ -4,8 +4,7 @@ import React from "react"; import { InMemoryCache } from "@apollo/client/cache"; import { ApolloClient } from "@apollo/client/core"; import { ApolloLink } from "@apollo/client/link/core"; -import { ApolloProvider } from "@apollo/client/react/context"; -import { useApolloClient } from "@apollo/client/react/hooks"; +import { ApolloProvider, useApolloClient } from "@apollo/client/react"; import { InvariantError } from "@apollo/client/utilities/invariant"; describe("useApolloClient Hook", () => { diff --git a/src/react/hooks/__tests__/useBackgroundQuery.test.tsx b/src/react/hooks/__tests__/useBackgroundQuery.test.tsx index 6c819bed675..00a2a86f8d4 100644 --- a/src/react/hooks/__tests__/useBackgroundQuery.test.tsx +++ b/src/react/hooks/__tests__/useBackgroundQuery.test.tsx @@ -25,12 +25,12 @@ import { split, } from "@apollo/client/core"; import type { Masked, MaskedDocumentNode } from "@apollo/client/masking"; -import { ApolloProvider } from "@apollo/client/react/context"; import { + ApolloProvider, skipToken, useBackgroundQuery, useReadQuery, -} from "@apollo/client/react/hooks"; +} from "@apollo/client/react"; import type { QueryRef, QueryReference } from "@apollo/client/react/internal"; import type { MockedResponse } from "@apollo/client/testing"; import { diff --git a/src/react/hooks/__tests__/useFragment.test.tsx b/src/react/hooks/__tests__/useFragment.test.tsx index d3a70251ff4..87337951c57 100644 --- a/src/react/hooks/__tests__/useFragment.test.tsx +++ b/src/react/hooks/__tests__/useFragment.test.tsx @@ -34,8 +34,7 @@ import { InMemoryCache, } from "@apollo/client/core"; import type { FragmentType } from "@apollo/client/masking"; -import { ApolloProvider } from "@apollo/client/react/context"; -import { useFragment, useQuery } from "@apollo/client/react/hooks"; +import { ApolloProvider, useFragment, useQuery } from "@apollo/client/react"; import { spyOnConsole } from "@apollo/client/testing/internal"; import { MockedProvider } from "@apollo/client/testing/react"; import { concatPagination } from "@apollo/client/utilities"; diff --git a/src/react/hooks/__tests__/useLazyQuery.test.tsx b/src/react/hooks/__tests__/useLazyQuery.test.tsx index 5e605e87527..a66a73cf8cd 100644 --- a/src/react/hooks/__tests__/useLazyQuery.test.tsx +++ b/src/react/hooks/__tests__/useLazyQuery.test.tsx @@ -30,8 +30,7 @@ import type { MaskedDocumentNode, Unmasked, } from "@apollo/client/masking"; -import { ApolloProvider } from "@apollo/client/react"; -import { useLazyQuery } from "@apollo/client/react/hooks"; +import { ApolloProvider, useLazyQuery } from "@apollo/client/react"; import { MockLink, mockSingleLink, diff --git a/src/react/hooks/__tests__/useLoadableQuery.test.tsx b/src/react/hooks/__tests__/useLoadableQuery.test.tsx index 8542612e78f..7a47b049df0 100644 --- a/src/react/hooks/__tests__/useLoadableQuery.test.tsx +++ b/src/react/hooks/__tests__/useLoadableQuery.test.tsx @@ -32,8 +32,11 @@ import { split, } from "@apollo/client/core"; import type { QueryRef } from "@apollo/client/react"; -import { ApolloProvider } from "@apollo/client/react/context"; -import { useLoadableQuery, useReadQuery } from "@apollo/client/react/hooks"; +import { + ApolloProvider, + useLoadableQuery, + useReadQuery, +} from "@apollo/client/react"; import type { MockedResponse } from "@apollo/client/testing"; import { MockLink, MockSubscriptionLink, wait } from "@apollo/client/testing"; import type { SimpleCaseData } from "@apollo/client/testing/internal"; diff --git a/src/react/hooks/__tests__/useMutation.test.tsx b/src/react/hooks/__tests__/useMutation.test.tsx index 0010826af57..c3c8e0afd12 100644 --- a/src/react/hooks/__tests__/useMutation.test.tsx +++ b/src/react/hooks/__tests__/useMutation.test.tsx @@ -34,8 +34,7 @@ import { import { BatchHttpLink } from "@apollo/client/link/batch-http"; import type { FetchResult } from "@apollo/client/link/core"; import type { Masked } from "@apollo/client/masking"; -import { ApolloProvider } from "@apollo/client/react/context"; -import { useMutation, useQuery } from "@apollo/client/react/hooks"; +import { ApolloProvider, useMutation, useQuery } from "@apollo/client/react"; import type { MockedResponse } from "@apollo/client/testing"; import { MockLink, diff --git a/src/react/hooks/__tests__/useQuery.test.tsx b/src/react/hooks/__tests__/useQuery.test.tsx index 091dac2a5e0..4f5e4324715 100644 --- a/src/react/hooks/__tests__/useQuery.test.tsx +++ b/src/react/hooks/__tests__/useQuery.test.tsx @@ -33,12 +33,12 @@ import { } from "@apollo/client/core"; import { ApolloLink } from "@apollo/client/link/core"; import type { Unmasked } from "@apollo/client/masking"; -import { ApolloProvider } from "@apollo/client/react/context"; import { + ApolloProvider, useLazyQuery, useMutation, useQuery, -} from "@apollo/client/react/hooks"; +} from "@apollo/client/react"; import type { MockedResponse } from "@apollo/client/testing"; import { MockLink, diff --git a/src/react/hooks/__tests__/useQueryRefHandlers.test.tsx b/src/react/hooks/__tests__/useQueryRefHandlers.test.tsx index 631332b2318..33dd8ef0d1c 100644 --- a/src/react/hooks/__tests__/useQueryRefHandlers.test.tsx +++ b/src/react/hooks/__tests__/useQueryRefHandlers.test.tsx @@ -15,13 +15,13 @@ import { NetworkStatus, split, } from "@apollo/client/core"; -import { createQueryPreloader } from "@apollo/client/react"; import { + createQueryPreloader, useBackgroundQuery, useLoadableQuery, useQueryRefHandlers, useReadQuery, -} from "@apollo/client/react/hooks"; +} from "@apollo/client/react"; import type { QueryRef } from "@apollo/client/react/internal"; import type { MockedResponse } from "@apollo/client/testing"; import { MockLink, MockSubscriptionLink } from "@apollo/client/testing"; diff --git a/src/react/hooks/__tests__/useReactiveVar.test.tsx b/src/react/hooks/__tests__/useReactiveVar.test.tsx index c273e3def16..4041c46db9e 100644 --- a/src/react/hooks/__tests__/useReactiveVar.test.tsx +++ b/src/react/hooks/__tests__/useReactiveVar.test.tsx @@ -2,7 +2,7 @@ import { act, render, screen, waitFor } from "@testing-library/react"; import React, { StrictMode, useEffect } from "react"; import { makeVar } from "@apollo/client/core"; -import { useReactiveVar } from "@apollo/client/react/hooks"; +import { useReactiveVar } from "@apollo/client/react"; const IS_REACT_18 = React.version.startsWith("18"); const IS_REACT_19 = React.version.startsWith("19"); diff --git a/src/react/hooks/__tests__/useSubscription.test.tsx b/src/react/hooks/__tests__/useSubscription.test.tsx index 1bf15cd060a..c1ffa7a8f4a 100644 --- a/src/react/hooks/__tests__/useSubscription.test.tsx +++ b/src/react/hooks/__tests__/useSubscription.test.tsx @@ -17,8 +17,7 @@ import { CombinedProtocolErrors, } from "@apollo/client/errors"; import type { Masked, MaskedDocumentNode } from "@apollo/client/masking"; -import { ApolloProvider } from "@apollo/client/react/context"; -import { useSubscription } from "@apollo/client/react/hooks"; +import { ApolloProvider, useSubscription } from "@apollo/client/react"; import { MockSubscriptionLink, tick, wait } from "@apollo/client/testing"; import { mockMultipartSubscriptionStream } from "@apollo/client/testing/internal"; import { InvariantError } from "@apollo/client/utilities/invariant"; diff --git a/src/react/hooks/__tests__/useSuspenseFragment.test.tsx b/src/react/hooks/__tests__/useSuspenseFragment.test.tsx index d64df730cbe..1772b88022f 100644 --- a/src/react/hooks/__tests__/useSuspenseFragment.test.tsx +++ b/src/react/hooks/__tests__/useSuspenseFragment.test.tsx @@ -18,8 +18,7 @@ import type { TypedDocumentNode, } from "@apollo/client/core"; import { ApolloClient, gql, InMemoryCache } from "@apollo/client/core"; -import { ApolloProvider } from "@apollo/client/react/context"; -import { useSuspenseFragment } from "@apollo/client/react/hooks"; +import { ApolloProvider, useSuspenseFragment } from "@apollo/client/react"; import { MockSubscriptionLink, wait } from "@apollo/client/testing"; import { renderAsync, spyOnConsole } from "@apollo/client/testing/internal"; import { MockedProvider } from "@apollo/client/testing/react"; diff --git a/src/react/hooks/__tests__/useSuspenseQuery.test.tsx b/src/react/hooks/__tests__/useSuspenseQuery.test.tsx index 829a4d8dd98..ddfe0ecd6df 100644 --- a/src/react/hooks/__tests__/useSuspenseQuery.test.tsx +++ b/src/react/hooks/__tests__/useSuspenseQuery.test.tsx @@ -37,9 +37,11 @@ import type { MaskedDocumentNode, Unmasked, } from "@apollo/client/masking"; -import { skipToken } from "@apollo/client/react"; -import { ApolloProvider } from "@apollo/client/react/context"; -import { useSuspenseQuery } from "@apollo/client/react/hooks"; +import { + ApolloProvider, + skipToken, + useSuspenseQuery, +} from "@apollo/client/react"; import type { MockedResponse } from "@apollo/client/testing"; import { MockLink, MockSubscriptionLink } from "@apollo/client/testing"; import type { @@ -372,7 +374,7 @@ describe("useSuspenseQuery", () => { }); }).toThrowError( new InvariantError( - "Running a Query requires a graphql Query, but a Mutation was used instead." + "Running a query requires a graphql query, but a mutation was used instead." ) ); }); diff --git a/src/react/hooks/index.ts b/src/react/hooks/index.ts deleted file mode 100644 index fc9090f157c..00000000000 --- a/src/react/hooks/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -export { useApolloClient } from "./useApolloClient.js"; -export { useLazyQuery } from "./useLazyQuery.js"; -export { useMutation } from "./useMutation.js"; -export { useQuery } from "./useQuery.js"; -export { useSubscription } from "./useSubscription.js"; -export { useReactiveVar } from "./useReactiveVar.js"; -export { useFragment } from "./useFragment.js"; -export { useSuspenseQuery } from "./useSuspenseQuery.js"; -export { useBackgroundQuery } from "./useBackgroundQuery.js"; -export { useSuspenseFragment } from "./useSuspenseFragment.js"; -export { useLoadableQuery } from "./useLoadableQuery.js"; -export { useQueryRefHandlers } from "./useQueryRefHandlers.js"; -export { useReadQuery } from "./useReadQuery.js"; -export { skipToken } from "./constants.js"; -export type { SkipToken } from "./constants.js"; diff --git a/src/react/hooks/internal/wrapHook.ts b/src/react/hooks/internal/wrapHook.ts index dd24c39a4c3..0d9a61676bd 100644 --- a/src/react/hooks/internal/wrapHook.ts +++ b/src/react/hooks/internal/wrapHook.ts @@ -11,7 +11,7 @@ import type { useReadQuery, useSuspenseFragment, useSuspenseQuery, -} from "@apollo/client/react/hooks"; +} from "@apollo/client/react"; import type { QueryManager } from "../../../core/QueryManager.js"; // direct import to avoid circular dependency diff --git a/src/react/hooks/useApolloClient.ts b/src/react/hooks/useApolloClient.ts index 68a44f270f8..2cae32fedd9 100644 --- a/src/react/hooks/useApolloClient.ts +++ b/src/react/hooks/useApolloClient.ts @@ -1,9 +1,10 @@ import * as React from "react"; import type { ApolloClient } from "@apollo/client/core"; -import { getApolloContext } from "@apollo/client/react/context"; import { invariant } from "@apollo/client/utilities/invariant"; +import { getApolloContext } from "../context/ApolloContext.js"; + /** * @example * ```jsx diff --git a/src/react/hooks/useMutation.ts b/src/react/hooks/useMutation.ts index bc8fa5aa2f1..c7e519618c4 100644 --- a/src/react/hooks/useMutation.ts +++ b/src/react/hooks/useMutation.ts @@ -1,12 +1,12 @@ import type { TypedDocumentNode } from "@graphql-typed-document-node/core"; import { equal } from "@wry/equality"; -import type { DocumentNode } from "graphql"; import * as React from "react"; import type { ApolloCache, ApolloClient, DefaultContext, + DocumentNode, ErrorLike, ErrorPolicy, FetchResult, @@ -21,7 +21,6 @@ import type { OperationVariables, Unmasked, } from "@apollo/client/core"; -import { DocumentType, verifyDocumentType } from "@apollo/client/react/parser"; import type { NoInfer } from "@apollo/client/utilities"; import { mergeOptions } from "@apollo/client/utilities"; @@ -205,7 +204,6 @@ export function useMutation< > ): useMutation.ResultTuple { const client = useApolloClient(options?.client); - verifyDocumentType(mutation, DocumentType.Mutation); const [result, setResult] = React.useState< Omit, "reset"> >(() => createInitialResult(client)); diff --git a/src/react/hooks/useQuery.ts b/src/react/hooks/useQuery.ts index 9d0740916f2..c318860e272 100644 --- a/src/react/hooks/useQuery.ts +++ b/src/react/hooks/useQuery.ts @@ -37,7 +37,6 @@ import type { } from "@apollo/client/core"; import { NetworkStatus } from "@apollo/client/core"; import type { MaybeMasked, Unmasked } from "@apollo/client/masking"; -import { DocumentType, verifyDocumentType } from "@apollo/client/react/parser"; import type { NoInfer } from "@apollo/client/utilities"; import { maybeDeepFreeze, mergeOptions } from "@apollo/client/utilities"; @@ -259,8 +258,6 @@ function useQuery_( function createState( previous?: InternalState ): InternalState { - verifyDocumentType(query, DocumentType.Query); - const observable = client.watchQuery(watchQueryOptions); return { diff --git a/src/react/hooks/useSubscription.ts b/src/react/hooks/useSubscription.ts index 0862ed3474f..c44cd89a261 100644 --- a/src/react/hooks/useSubscription.ts +++ b/src/react/hooks/useSubscription.ts @@ -14,7 +14,6 @@ import type { SubscribeResult, } from "@apollo/client/core"; import type { MaybeMasked } from "@apollo/client/masking"; -import { DocumentType, verifyDocumentType } from "@apollo/client/react/parser"; import type { NoInfer } from "@apollo/client/utilities"; import { invariant } from "@apollo/client/utilities/invariant"; @@ -185,7 +184,6 @@ export function useSubscription< options: useSubscription.Options, NoInfer> = {} ): useSubscription.Result { const client = useApolloClient(options.client); - verifyDocumentType(subscription, DocumentType.Subscription); const { skip, diff --git a/src/react/hooks/useSuspenseQuery.ts b/src/react/hooks/useSuspenseQuery.ts index 30c8cac250f..3e2a9b6f4de 100644 --- a/src/react/hooks/useSuspenseQuery.ts +++ b/src/react/hooks/useSuspenseQuery.ts @@ -24,7 +24,6 @@ import type { RefetchFunction, } from "@apollo/client/react/internal"; import { getSuspenseCache } from "@apollo/client/react/internal"; -import { DocumentType, verifyDocumentType } from "@apollo/client/react/parser"; import type { DeepPartial, NoInfer } from "@apollo/client/utilities"; import { __DEV__ } from "@apollo/client/utilities/environment"; import { invariant } from "@apollo/client/utilities/invariant"; @@ -341,9 +340,8 @@ function useSuspenseQuery_< } function validateOptions(options: WatchQueryOptions) { - const { query, fetchPolicy, returnPartialData } = options; + const { fetchPolicy, returnPartialData } = options; - verifyDocumentType(query, DocumentType.Query); validateFetchPolicy(fetchPolicy); validatePartialDataReturn(fetchPolicy, returnPartialData); } diff --git a/src/react/index.react-server.ts b/src/react/index.react-server.ts index 994cacd1411..68ad8f37029 100644 --- a/src/react/index.react-server.ts +++ b/src/react/index.react-server.ts @@ -20,12 +20,6 @@ function missingFeatureWarning( // eslint-disable-next-line no-restricted-syntax export type * from "./index.js"; -export { - DocumentType, - operationName, - parser, -} from "@apollo/client/react/parser"; - // prettier-ignore export const ApolloConsumer = missingFeatureWarning("component", "ApolloConsumer"); // prettier-ignore diff --git a/src/react/index.ts b/src/react/index.ts index 775a48101d2..e6641ebaa56 100644 --- a/src/react/index.ts +++ b/src/react/index.ts @@ -1,34 +1,23 @@ -export type { ApolloContextValue } from "@apollo/client/react/context"; -export { - ApolloConsumer, - ApolloProvider, - getApolloContext, -} from "@apollo/client/react/context"; +export type { ApolloContextValue } from "./context/ApolloContext.js"; +export { ApolloConsumer } from "./context/ApolloConsumer.js"; +export { getApolloContext } from "./context/ApolloContext.js"; +export { ApolloProvider } from "./context/ApolloProvider.js"; -export type { SkipToken } from "@apollo/client/react/hooks"; -export { - skipToken, - useApolloClient, - useBackgroundQuery, - useFragment, - useLazyQuery, - useLoadableQuery, - useMutation, - useQuery, - useQueryRefHandlers, - useReactiveVar, - useReadQuery, - useSubscription, - useSuspenseFragment, - useSuspenseQuery, -} from "@apollo/client/react/hooks"; - -export type { IDocumentDefinition } from "@apollo/client/react/parser"; -export { - DocumentType, - operationName, - parser, -} from "@apollo/client/react/parser"; +export { useApolloClient } from "./hooks/useApolloClient.js"; +export { useLazyQuery } from "./hooks/useLazyQuery.js"; +export { useMutation } from "./hooks/useMutation.js"; +export { useQuery } from "./hooks/useQuery.js"; +export { useSubscription } from "./hooks/useSubscription.js"; +export { useReactiveVar } from "./hooks/useReactiveVar.js"; +export { useFragment } from "./hooks/useFragment.js"; +export { useSuspenseQuery } from "./hooks/useSuspenseQuery.js"; +export { useBackgroundQuery } from "./hooks/useBackgroundQuery.js"; +export { useSuspenseFragment } from "./hooks/useSuspenseFragment.js"; +export { useLoadableQuery } from "./hooks/useLoadableQuery.js"; +export { useQueryRefHandlers } from "./hooks/useQueryRefHandlers.js"; +export { useReadQuery } from "./hooks/useReadQuery.js"; +export { skipToken } from "./hooks/constants.js"; +export type { SkipToken } from "./hooks/constants.js"; export type { PreloadQueryFetchPolicy, diff --git a/src/react/parser/__tests__/parser.test.ts b/src/react/parser/__tests__/parser.test.ts deleted file mode 100644 index fd424a90132..00000000000 --- a/src/react/parser/__tests__/parser.test.ts +++ /dev/null @@ -1,227 +0,0 @@ -import { gql } from "graphql-tag"; - -import { DocumentType, parser } from "@apollo/client/react/parser"; - -type OperationDefinition = any; - -describe("parser", () => { - it("should error if both a query and a mutation is present", () => { - const query = gql` - query { - user { - name - } - } - - mutation ($t: String) { - addT(t: $t) { - user { - name - } - } - } - `; - - expect(parser.bind(null, query)).toThrowError(/react-apollo only supports/); - }); - - it("should error if multiple operations are present", () => { - const query = gql` - query One { - user { - name - } - } - - query Two { - user { - name - } - } - `; - - expect(parser.bind(null, query)).toThrowError(/react-apollo only supports/); - }); - - it("should error if not a DocumentNode", () => { - const query = ` - query One { user { name } } - `; - expect(parser.bind(null, query as any)).toThrowError( - /not a valid GraphQL DocumentNode/ - ); - }); - - it("should return the name of the operation", () => { - const query = gql` - query One { - user { - name - } - } - `; - expect(parser(query).name).toBe("One"); - - const mutation = gql` - mutation One { - user { - name - } - } - `; - expect(parser(mutation).name).toBe("One"); - - const subscription = gql` - subscription One { - user { - name - } - } - `; - expect(parser(subscription).name).toBe("One"); - }); - - it("should return data as the name of the operation if not named", () => { - const query = gql` - query { - user { - name - } - } - `; - expect(parser(query).name).toBe("data"); - - const unnamedQuery = gql` - { - user { - name - } - } - `; - expect(parser(unnamedQuery).name).toBe("data"); - - const mutation = gql` - mutation { - user { - name - } - } - `; - expect(parser(mutation).name).toBe("data"); - - const subscription = gql` - subscription { - user { - name - } - } - `; - expect(parser(subscription).name).toBe("data"); - }); - - it("should return the type of operation", () => { - const query = gql` - query One { - user { - name - } - } - `; - expect(parser(query).type).toBe(DocumentType.Query); - - const unnamedQuery = gql` - { - user { - name - } - } - `; - expect(parser(unnamedQuery).type).toBe(DocumentType.Query); - - const mutation = gql` - mutation One { - user { - name - } - } - `; - expect(parser(mutation).type).toBe(DocumentType.Mutation); - - const subscription = gql` - subscription One { - user { - name - } - } - `; - expect(parser(subscription).type).toBe(DocumentType.Subscription); - }); - - it("should return the variable definitions of the operation", () => { - const query = gql` - query One($t: String!) { - user(t: $t) { - name - } - } - `; - let definition = query.definitions[0] as OperationDefinition; - expect(parser(query).variables).toEqual(definition.variableDefinitions); - - const mutation = gql` - mutation One($t: String!) { - user(t: $t) { - name - } - } - `; - definition = mutation.definitions[0] as OperationDefinition; - expect(parser(mutation).variables).toEqual(definition.variableDefinitions); - - const subscription = gql` - subscription One($t: String!) { - user(t: $t) { - name - } - } - `; - definition = subscription.definitions[0] as OperationDefinition; - expect(parser(subscription).variables).toEqual( - definition.variableDefinitions - ); - }); - - it("should not error if the operation has no variables", () => { - const query = gql` - query { - user(t: $t) { - name - } - } - `; - let definition = query.definitions[0] as OperationDefinition; - expect(parser(query).variables).toEqual(definition.variableDefinitions); - - const mutation = gql` - mutation { - user(t: $t) { - name - } - } - `; - definition = mutation.definitions[0] as OperationDefinition; - expect(parser(mutation).variables).toEqual(definition.variableDefinitions); - - const subscription = gql` - subscription { - user(t: $t) { - name - } - } - `; - definition = subscription.definitions[0] as OperationDefinition; - expect(parser(subscription).variables).toEqual( - definition.variableDefinitions - ); - }); -}); diff --git a/src/react/parser/index.ts b/src/react/parser/index.ts deleted file mode 100644 index f9c3ea439f4..00000000000 --- a/src/react/parser/index.ts +++ /dev/null @@ -1,173 +0,0 @@ -import type { - DefinitionNode, - DocumentNode, - OperationDefinitionNode, - VariableDefinitionNode, -} from "graphql"; - -import { - AutoCleanedWeakCache, - cacheSizes, - defaultCacheSizes, -} from "@apollo/client/utilities"; -import { __DEV__ } from "@apollo/client/utilities/environment"; -import { registerGlobalCache } from "@apollo/client/utilities/internal"; -import { invariant } from "@apollo/client/utilities/invariant"; - -export enum DocumentType { - Query, - Mutation, - Subscription, -} - -export interface IDocumentDefinition { - type: DocumentType; - name: string; - variables: ReadonlyArray; -} - -let cache: - | undefined - | AutoCleanedWeakCache< - DocumentNode, - { - name: string; - type: DocumentType; - variables: readonly VariableDefinitionNode[]; - } - >; - -export function operationName(type: DocumentType) { - let name; - switch (type) { - case DocumentType.Query: - name = "Query"; - break; - case DocumentType.Mutation: - name = "Mutation"; - break; - case DocumentType.Subscription: - name = "Subscription"; - break; - } - return name; -} - -// This parser is mostly used to safety check incoming documents. -export function parser(document: DocumentNode): IDocumentDefinition { - if (!cache) { - cache = new AutoCleanedWeakCache( - cacheSizes.parser || defaultCacheSizes.parser - ); - } - const cached = cache.get(document); - if (cached) return cached; - - let variables, type, name; - - invariant( - !!document && !!document.kind, - `Argument of %s passed to parser was not a valid GraphQL ` + - `DocumentNode. You may need to use 'graphql-tag' or another method ` + - `to convert your operation into a document`, - document - ); - - const fragments: DefinitionNode[] = []; - const queries: DefinitionNode[] = []; - const mutations: DefinitionNode[] = []; - const subscriptions: DefinitionNode[] = []; - - for (const x of document.definitions) { - if (x.kind === "FragmentDefinition") { - fragments.push(x); - continue; - } - - if (x.kind === "OperationDefinition") { - switch (x.operation) { - case "query": - queries.push(x); - break; - case "mutation": - mutations.push(x); - break; - case "subscription": - subscriptions.push(x); - break; - } - } - } - - invariant( - !fragments.length || - queries.length || - mutations.length || - subscriptions.length, - `Passing only a fragment to 'graphql' is not yet supported. ` + - `You must include a query, subscription or mutation as well` - ); - - invariant( - queries.length + mutations.length + subscriptions.length <= 1, - `react-apollo only supports a query, subscription, or a mutation per HOC. ` + - `%s had %s queries, %s ` + - `subscriptions and %s mutations. ` + - `You can use 'compose' to join multiple operation types to a component`, - document, - queries.length, - subscriptions.length, - mutations.length - ); - - type = queries.length ? DocumentType.Query : DocumentType.Mutation; - if (!queries.length && !mutations.length) type = DocumentType.Subscription; - - const definitions = - queries.length ? queries - : mutations.length ? mutations - : subscriptions; - - invariant( - definitions.length === 1, - `react-apollo only supports one definition per HOC. %s had ` + - `%s definitions. ` + - `You can use 'compose' to join multiple operation types to a component`, - document, - definitions.length - ); - - const definition = definitions[0] as OperationDefinitionNode; - variables = definition.variableDefinitions || []; - - if (definition.name && definition.name.kind === "Name") { - name = definition.name.value; - } else { - name = "data"; // fallback to using data if no name - } - - const payload = { name, type, variables }; - cache.set(document, payload); - return payload; -} - -parser.resetCache = () => { - cache = undefined; -}; - -if (__DEV__) { - registerGlobalCache("parser", () => (cache ? cache.size : 0)); -} - -export function verifyDocumentType(document: DocumentNode, type: DocumentType) { - const operation = parser(document); - const requiredOperationName = operationName(type); - const usedOperationName = operationName(operation.type); - invariant( - operation.type === type, - `Running a %s requires a graphql ` + `%s, but a %s was used instead.`, - requiredOperationName, - requiredOperationName, - usedOperationName - ); -} diff --git a/src/react/query-preloader/__tests__/createQueryPreloader.test.tsx b/src/react/query-preloader/__tests__/createQueryPreloader.test.tsx index 494ceb7e2f9..72ccc18a519 100644 --- a/src/react/query-preloader/__tests__/createQueryPreloader.test.tsx +++ b/src/react/query-preloader/__tests__/createQueryPreloader.test.tsx @@ -24,9 +24,11 @@ import { NetworkStatus, } from "@apollo/client/core"; import type { Masked } from "@apollo/client/masking"; -import { createQueryPreloader } from "@apollo/client/react"; -import { ApolloProvider } from "@apollo/client/react/context"; -import { useReadQuery } from "@apollo/client/react/hooks"; +import { + ApolloProvider, + createQueryPreloader, + useReadQuery, +} from "@apollo/client/react"; import type { PreloadedQueryRef, QueryRef, diff --git a/src/react/ssr/__tests__/getDataFromTree.test.tsx b/src/react/ssr/__tests__/getDataFromTree.test.tsx index db4d108d77d..076a775eab0 100644 --- a/src/react/ssr/__tests__/getDataFromTree.test.tsx +++ b/src/react/ssr/__tests__/getDataFromTree.test.tsx @@ -8,8 +8,11 @@ import React from "react"; import { InMemoryCache as Cache } from "@apollo/client/cache"; import type { TypedDocumentNode } from "@apollo/client/core"; import { ApolloClient, CombinedGraphQLErrors } from "@apollo/client/core"; -import { ApolloProvider, getApolloContext } from "@apollo/client/react/context"; -import { useQuery } from "@apollo/client/react/hooks"; +import { + ApolloProvider, + getApolloContext, + useQuery, +} from "@apollo/client/react"; import { getDataFromTree } from "@apollo/client/react/ssr"; import { mockSingleLink } from "@apollo/client/testing"; diff --git a/src/react/ssr/__tests__/useQuery.test.tsx b/src/react/ssr/__tests__/useQuery.test.tsx index 2f2263ac8bc..68039637b74 100644 --- a/src/react/ssr/__tests__/useQuery.test.tsx +++ b/src/react/ssr/__tests__/useQuery.test.tsx @@ -6,8 +6,11 @@ import { renderToStaticMarkup, renderToString } from "react-dom/server"; import { InMemoryCache } from "@apollo/client/cache"; import type { TypedDocumentNode } from "@apollo/client/core"; import { ApolloClient } from "@apollo/client/core"; -import { ApolloProvider } from "@apollo/client/react/context"; -import { useApolloClient, useQuery } from "@apollo/client/react/hooks"; +import { + ApolloProvider, + useApolloClient, + useQuery, +} from "@apollo/client/react"; import { prerenderStatic, renderToStringWithData, diff --git a/src/react/ssr/__tests__/useReactiveVar.test.tsx b/src/react/ssr/__tests__/useReactiveVar.test.tsx index c6b2528cae3..372394e8e5b 100644 --- a/src/react/ssr/__tests__/useReactiveVar.test.tsx +++ b/src/react/ssr/__tests__/useReactiveVar.test.tsx @@ -2,7 +2,7 @@ import React from "react"; import { makeVar } from "@apollo/client/core"; -import { useReactiveVar } from "@apollo/client/react/hooks"; +import { useReactiveVar } from "@apollo/client/react"; import { renderToStringWithData } from "@apollo/client/react/ssr"; import { spyOnConsole } from "@apollo/client/testing/internal"; diff --git a/src/react/ssr/prerenderStatic.tsx b/src/react/ssr/prerenderStatic.tsx index 4c2aa36141b..29c4e2701bc 100644 --- a/src/react/ssr/prerenderStatic.tsx +++ b/src/react/ssr/prerenderStatic.tsx @@ -9,7 +9,7 @@ import type { ObservableQuery, OperationVariables, } from "@apollo/client/core"; -import { getApolloContext } from "@apollo/client/react/context"; +import { getApolloContext } from "@apollo/client/react"; import { wrapperSymbol } from "@apollo/client/react/internal"; import { canonicalStringify } from "@apollo/client/utilities"; import { invariant } from "@apollo/client/utilities/invariant"; diff --git a/src/react/types/deprecated.ts b/src/react/types/deprecated.ts index 8c5cb5617cf..fd096498bab 100644 --- a/src/react/types/deprecated.ts +++ b/src/react/types/deprecated.ts @@ -3,19 +3,18 @@ import type { DefaultContext, OperationVariables, } from "@apollo/client/core"; -import type { - useBackgroundQuery, - useFragment, - useLazyQuery, - useLoadableQuery, - useMutation, - useQuery, - useQueryRefHandlers, - useReadQuery, - useSubscription, - useSuspenseFragment, - useSuspenseQuery, -} from "@apollo/client/react/hooks"; + +import type { useBackgroundQuery } from "../hooks/useBackgroundQuery.js"; +import type { useFragment } from "../hooks/useFragment.js"; +import type { useLazyQuery } from "../hooks/useLazyQuery.js"; +import type { useLoadableQuery } from "../hooks/useLoadableQuery.js"; +import type { useMutation } from "../hooks/useMutation.js"; +import type { useQuery } from "../hooks/useQuery.js"; +import type { useQueryRefHandlers } from "../hooks/useQueryRefHandlers.js"; +import type { useReadQuery } from "../hooks/useReadQuery.js"; +import type { useSubscription } from "../hooks/useSubscription.js"; +import type { useSuspenseFragment } from "../hooks/useSuspenseFragment.js"; +import type { useSuspenseQuery } from "../hooks/useSuspenseQuery.js"; /** @deprecated Use `useQuery.Options` instead */ export type QueryHookOptions< diff --git a/src/testing/react/MockedProvider.tsx b/src/testing/react/MockedProvider.tsx index eb816b3248c..618dabc0d87 100644 --- a/src/testing/react/MockedProvider.tsx +++ b/src/testing/react/MockedProvider.tsx @@ -6,7 +6,7 @@ import type { DefaultOptions } from "@apollo/client/core"; import type { Resolvers } from "@apollo/client/core"; import { ApolloClient } from "@apollo/client/core"; import type { ApolloLink } from "@apollo/client/link/core"; -import { ApolloProvider } from "@apollo/client/react/context"; +import { ApolloProvider } from "@apollo/client/react"; import type { MockedResponse } from "@apollo/client/testing/core"; import { MockLink } from "@apollo/client/testing/core"; diff --git a/src/testing/react/__tests__/mockSubscriptionLink.test.tsx b/src/testing/react/__tests__/mockSubscriptionLink.test.tsx index f98a23d36f6..a01fee6f660 100644 --- a/src/testing/react/__tests__/mockSubscriptionLink.test.tsx +++ b/src/testing/react/__tests__/mockSubscriptionLink.test.tsx @@ -4,8 +4,7 @@ import React from "react"; import { InMemoryCache as Cache } from "@apollo/client/cache"; import { ApolloClient } from "@apollo/client/core"; -import { ApolloProvider } from "@apollo/client/react/context"; -import { useSubscription } from "@apollo/client/react/hooks"; +import { ApolloProvider, useSubscription } from "@apollo/client/react"; import { MockSubscriptionLink } from "@apollo/client/testing/core"; describe("mockSubscriptionLink", () => { diff --git a/src/utilities/caching/__tests__/getMemoryInternals.ts b/src/utilities/caching/__tests__/getMemoryInternals.ts index 03900b5ad18..0199f9c922f 100644 --- a/src/utilities/caching/__tests__/getMemoryInternals.ts +++ b/src/utilities/caching/__tests__/getMemoryInternals.ts @@ -10,8 +10,6 @@ import { } from "@apollo/client/core"; import { createPersistedQueryLink } from "@apollo/client/link/persisted-queries"; import { removeTypenameFromVariables } from "@apollo/client/link/remove-typename"; -// importing react so the `parser` cache initializes -import "@apollo/client/react"; import { cacheSizes } from "@apollo/client/utilities"; // this is compiled away so we need to import it from sources @@ -25,7 +23,6 @@ function sha256(data: string) { } const defaultCacheSizesAsObject = { - parser: defaultCacheSizes["parser"], canonicalStringify: defaultCacheSizes["canonicalStringify"], print: defaultCacheSizes["print"], "documentTransform.cache": defaultCacheSizes["documentTransform.cache"], @@ -70,7 +67,6 @@ it("returns information about cache usage (empty caches)", () => { expect(client.getMemoryInternals?.()).toEqual({ limits: defaultCacheSizesAsObject, sizes: { - parser: 0, canonicalStringify: 0, print: 0, addTypenameDocumentTransform: [ @@ -149,7 +145,6 @@ it("returns information about cache usage (some query triggered)", () => { expect(client.getMemoryInternals?.()).toStrictEqual({ limits: defaultCacheSizesAsObject, sizes: { - parser: 0, canonicalStringify: 0, print: 1, addTypenameDocumentTransform: [ diff --git a/src/utilities/caching/sizes.ts b/src/utilities/caching/sizes.ts index e1020ea3a6c..52a648eb0ce 100644 --- a/src/utilities/caching/sizes.ts +++ b/src/utilities/caching/sizes.ts @@ -43,23 +43,6 @@ export interface CacheSizes { * `DocumentNode`. */ print: number; - /** - * Cache size for the [`parser`](https://github.com/apollographql/apollo-client/blob/main/src/react/parser/index.ts) function. - * - * It is called with user-provided `DocumentNode`s. - * - * @defaultValue - * Defaults to `1000`. - * - * @remarks - * This method is called by HOCs and hooks. - * - * @privateRemarks - * This function is used directly in HOCs, and nowadays mainly accessed by - * calling `verifyDocumentType` from various hooks. - * It is called with a user-provided DocumentNode. - */ - parser: number; /** * Cache size for the cache of [`DocumentTransform`](https://github.com/apollographql/apollo-client/blob/main/src/utilities/graphql/DocumentTransform.ts) * instances with the `cache` option set to `true`. @@ -286,7 +269,7 @@ const cacheSizeSymbol = Symbol.for("apollo.cacheSize"); * You can directly modify this object, but any modification will * only have an effect on caches that are created after the modification. * - * So for global caches, such as `parser`, `canonicalStringify` and `print`, + * So for global caches, such as `canonicalStringify` and `print`, * you might need to call `.reset` on them, which will essentially re-create them. * * Alternatively, you can set `globalThis[Symbol.for("apollo.cacheSize")]` before @@ -295,14 +278,13 @@ const cacheSizeSymbol = Symbol.for("apollo.cacheSize"); * @example * ```ts * globalThis[Symbol.for("apollo.cacheSize")] = { - * parser: 100 + * print: 100 * } satisfies Partial // the `satisfies` is optional if using TypeScript * ``` */ export const cacheSizes: Partial = { ...global[cacheSizeSymbol] }; export const enum defaultCacheSizes { - parser = 1000, canonicalStringify = 1000, print = 2000, "documentTransform.cache" = 2000, diff --git a/src/utilities/graphql/getFromAST.ts b/src/utilities/graphql/getFromAST.ts index bb845ef7aba..e41320b018b 100644 --- a/src/utilities/graphql/getFromAST.ts +++ b/src/utilities/graphql/getFromAST.ts @@ -2,6 +2,7 @@ import type { DocumentNode, FragmentDefinitionNode, OperationDefinitionNode, + OperationTypeNode, ValueNode, } from "graphql"; @@ -17,7 +18,10 @@ type OperationDefinitionWithName = OperationDefinitionNode & { }; // Checks the document for errors and throws an exception if there is an error. -export function checkDocument(doc: DocumentNode) { +export function checkDocument( + doc: DocumentNode, + expectedType?: OperationTypeNode +) { invariant( doc && doc.kind === "Document", `Expecting a parsed GraphQL document. Perhaps you need to wrap the query \ @@ -42,6 +46,16 @@ string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql` operations.length ); + if (expectedType) { + invariant( + operations.length == 1 && operations[0].operation === expectedType, + `Running a %s requires a graphql ` + `%s, but a %s was used instead.`, + expectedType, + expectedType, + operations[0].operation + ); + } + return doc; } diff --git a/src/utilities/internal/getMemoryInternals.ts b/src/utilities/internal/getMemoryInternals.ts index 6697722ad51..94a13c8627c 100644 --- a/src/utilities/internal/getMemoryInternals.ts +++ b/src/utilities/internal/getMemoryInternals.ts @@ -99,7 +99,6 @@ export const getApolloCacheMemoryInternals = function getCurrentCacheSizes() { // `defaultCacheSizes` is a `const enum` that will be inlined during build, so we have to reconstruct it's shape here const defaults: Record = { - parser: defaultCacheSizes["parser"], canonicalStringify: defaultCacheSizes["canonicalStringify"], print: defaultCacheSizes["print"], "documentTransform.cache": defaultCacheSizes["documentTransform.cache"], @@ -138,7 +137,6 @@ function _getApolloClientMemoryInternals(this: ApolloClient) { limits: getCurrentCacheSizes(), sizes: { print: globalCaches.print?.(), - parser: globalCaches.parser?.(), canonicalStringify: globalCaches.canonicalStringify?.(), links: linkInfo(this.link), queryManager: {