Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create branded QueryRef type without exposed properties #11824

Merged
merged 21 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
164 changes: 29 additions & 135 deletions .api-reports/api-report-react.md

Large diffs are not rendered by default.

151 changes: 17 additions & 134 deletions .api-reports/api-report-react_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -725,9 +725,6 @@ type FetchMoreFunction<TData, TVariables extends OperationVariables> = (fetchMor
}) => TData;
}) => Promise<ApolloQueryResult<TData>>;

// @public (undocumented)
type FetchMoreOptions<TData> = Parameters<ObservableQuery<TData>["fetchMore"]>[0];

// @public (undocumented)
interface FetchMoreQueryOptions<TVariables, TData = any> {
// (undocumented)
Expand Down Expand Up @@ -768,14 +765,6 @@ interface FragmentMap {
// @public (undocumented)
type FragmentMatcher = (rootValue: any, typeCondition: string, context: any) => boolean;

// @public (undocumented)
interface FulfilledPromise<TValue> extends Promise<TValue> {
// (undocumented)
status: "fulfilled";
// (undocumented)
value: TValue;
}

// @internal
const getApolloCacheMemoryInternals: (() => {
cache: {
Expand Down Expand Up @@ -860,58 +849,6 @@ interface IncrementalPayload<TData, TExtensions> {
path: Path;
}

// @public (undocumented)
class InternalQueryReference<TData = unknown> {
// Warning: (ae-forgotten-export) The symbol "InternalQueryReferenceOptions" needs to be exported by the entry point index.d.ts
constructor(observable: ObservableQuery<TData, any>, options: InternalQueryReferenceOptions);
// (undocumented)
applyOptions(watchQueryOptions: ObservedOptions): QueryRefPromise<TData>;
// Warning: (ae-forgotten-export) The symbol "ObservedOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
didChangeOptions(watchQueryOptions: ObservedOptions): boolean;
// (undocumented)
get disposed(): boolean;
// Warning: (ae-forgotten-export) The symbol "FetchMoreOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
fetchMore(options: FetchMoreOptions<TData>): Promise<ApolloQueryResult<TData>>;
// Warning: (ae-forgotten-export) The symbol "QueryKey" needs to be exported by the entry point index.d.ts
//
// (undocumented)
readonly key: QueryKey;
// Warning: (ae-forgotten-export) The symbol "Listener" needs to be exported by the entry point index.d.ts
//
// (undocumented)
listen(listener: Listener<TData>): () => void;
// (undocumented)
readonly observable: ObservableQuery<TData>;
// Warning: (ae-forgotten-export) The symbol "QueryRefPromise" needs to be exported by the entry point index.d.ts
//
// (undocumented)
promise: QueryRefPromise<TData>;
// (undocumented)
refetch(variables: OperationVariables | undefined): Promise<ApolloQueryResult<TData>>;
// (undocumented)
reinitialize(): void;
// (undocumented)
result: ApolloQueryResult<TData>;
// (undocumented)
retain(): () => void;
// (undocumented)
softRetain(): () => void;
// (undocumented)
get watchQueryOptions(): WatchQueryOptions<OperationVariables, TData>;
}

// @public (undocumented)
interface InternalQueryReferenceOptions {
// (undocumented)
autoDisposeTimeoutMs?: number;
// (undocumented)
onDispose?: () => void;
}

// 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
//
Expand Down Expand Up @@ -991,9 +928,6 @@ execute: LazyQueryExecFunction<TData, TVariables>,
result: QueryResult<TData, TVariables>
];

// @public (undocumented)
type Listener<TData> = (promise: QueryRefPromise<TData>) => void;

// @public (undocumented)
type LoadableQueryHookFetchPolicy = Extract<WatchQueryFetchPolicy, "cache-first" | "network-only" | "no-cache" | "cache-and-network">;

Expand Down Expand Up @@ -1323,14 +1257,6 @@ interface ObservableQueryFields<TData, TVariables extends OperationVariables> {
variables: TVariables | undefined;
}

// @public (undocumented)
const OBSERVED_CHANGED_OPTIONS: readonly ["canonizeResults", "context", "errorPolicy", "fetchPolicy", "refetchWritePolicy", "returnPartialData"];

// Warning: (ae-forgotten-export) The symbol "OBSERVED_CHANGED_OPTIONS" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type ObservedOptions = Pick<WatchQueryOptions, (typeof OBSERVED_CHANGED_OPTIONS)[number]>;

// @public (undocumented)
interface OnDataOptions<TData = any> {
// (undocumented)
Expand Down Expand Up @@ -1382,27 +1308,11 @@ type OperationVariables = Record<string, any>;
// @public (undocumented)
type Path = ReadonlyArray<string | number>;

// @public (undocumented)
interface PendingPromise<TValue> extends Promise<TValue> {
// (undocumented)
status: "pending";
}

// @public (undocumented)
type Primitive = null | undefined | string | number | boolean | symbol | bigint;

// @public (undocumented)
const PROMISE_SYMBOL: unique symbol;

// Warning: (ae-forgotten-export) The symbol "PendingPromise" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "FulfilledPromise" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "RejectedPromise" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type PromiseWithState<TValue> = PendingPromise<TValue> | FulfilledPromise<TValue> | RejectedPromise<TValue>;

// @public (undocumented)
const QUERY_REFERENCE_SYMBOL: unique symbol;
const QUERY_REF_BRAND: unique symbol;

// @public (undocumented)
interface QueryFunctionOptions<TData = any, TVariables extends OperationVariables = OperationVariables> extends BaseQueryOptions<TVariables, TData> {
Expand Down Expand Up @@ -1478,12 +1388,6 @@ class QueryInfo {
variables?: Record<string, any>;
}

// @public (undocumented)
interface QueryKey {
// (undocumented)
__queryKey?: string;
}

// @public (undocumented)
type QueryListener = (queryInfo: QueryInfo) => void;

Expand Down Expand Up @@ -1628,21 +1532,11 @@ interface QueryOptions<TVariables = OperationVariables, TData = any> {
}

// @public
interface QueryReference<TData = unknown, TVariables = unknown> {
interface QueryRef<TData = unknown, TVariables = unknown> {
// @internal (undocumented)
[PROMISE_SYMBOL]: QueryRefPromise<TData>;
// Warning: (ae-forgotten-export) The symbol "InternalQueryReference" needs to be exported by the entry point index.d.ts
//
// @internal (undocumented)
readonly [QUERY_REFERENCE_SYMBOL]: InternalQueryReference<TData>;
toPromise(): Promise<QueryReference<TData, TVariables>>;
[QUERY_REF_BRAND]?(variables: TVariables): TData;
}

// Warning: (ae-forgotten-export) The symbol "PromiseWithState" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type QueryRefPromise<TData> = PromiseWithState<ApolloQueryResult<TData>>;

// Warning: (ae-forgotten-export) The symbol "ObservableQueryFields" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
Expand Down Expand Up @@ -1744,14 +1638,6 @@ type RefetchQueryDescriptor = string | DocumentNode;
// @public (undocumented)
type RefetchWritePolicy = "merge" | "overwrite";

// @public (undocumented)
interface RejectedPromise<TValue> extends Promise<TValue> {
// (undocumented)
reason: unknown;
// (undocumented)
status: "rejected";
}

// @public (undocumented)
type RequestHandler = (operation: Operation, forward: NextLink) => Observable<FetchResult> | null;

Expand Down Expand Up @@ -1955,11 +1841,11 @@ interface UriFunction {
export function useApolloClient(override?: ApolloClient<object>): ApolloClient<object>;

// Warning: (ae-forgotten-export) The symbol "BackgroundQueryHookOptionsNoInfer" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "QueryReference" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "QueryRef" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export function useBackgroundQuery<TData, TVariables extends OperationVariables, TOptions extends Omit<BackgroundQueryHookOptions<TData>, "variables">>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: BackgroundQueryHookOptionsNoInfer<TData, TVariables> & TOptions): [
(QueryReference<TOptions["errorPolicy"] extends "ignore" | "all" ? TOptions["returnPartialData"] extends true ? DeepPartial<TData> | undefined : TData | undefined : TOptions["returnPartialData"] extends true ? DeepPartial<TData> : TData, TVariables> | (TOptions["skip"] extends boolean ? undefined : never)),
(QueryRef<TOptions["errorPolicy"] extends "ignore" | "all" ? TOptions["returnPartialData"] extends true ? DeepPartial<TData> | undefined : TData | undefined : TOptions["returnPartialData"] extends true ? DeepPartial<TData> : TData, TVariables> | (TOptions["skip"] extends boolean ? undefined : never)),
UseBackgroundQueryResult<TData, TVariables>
];

Expand All @@ -1968,15 +1854,15 @@ export function useBackgroundQuery<TData = unknown, TVariables extends Operation
returnPartialData: true;
errorPolicy: "ignore" | "all";
}): [
QueryReference<DeepPartial<TData> | undefined, TVariables>,
QueryRef<DeepPartial<TData> | undefined, TVariables>,
UseBackgroundQueryResult<TData, TVariables>
];

// @public (undocumented)
export function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: BackgroundQueryHookOptionsNoInfer<TData, TVariables> & {
errorPolicy: "ignore" | "all";
}): [
QueryReference<TData | undefined, TVariables>,
QueryRef<TData | undefined, TVariables>,
UseBackgroundQueryResult<TData, TVariables>
];

Expand All @@ -1985,31 +1871,28 @@ export function useBackgroundQuery<TData = unknown, TVariables extends Operation
skip: boolean;
returnPartialData: true;
}): [
QueryReference<DeepPartial<TData>, TVariables> | undefined,
QueryRef<DeepPartial<TData>, TVariables> | undefined,
UseBackgroundQueryResult<TData, TVariables>
];

// @public (undocumented)
export function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: BackgroundQueryHookOptionsNoInfer<TData, TVariables> & {
returnPartialData: true;
}): [
QueryReference<DeepPartial<TData>, TVariables>,
QueryRef<DeepPartial<TData>, TVariables>,
UseBackgroundQueryResult<TData, TVariables>
];

// @public (undocumented)
export function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: BackgroundQueryHookOptionsNoInfer<TData, TVariables> & {
skip: boolean;
}): [
QueryReference<TData, TVariables> | undefined,
QueryRef<TData, TVariables> | undefined,
UseBackgroundQueryResult<TData, TVariables>
];

// @public (undocumented)
export function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: BackgroundQueryHookOptionsNoInfer<TData, TVariables>): [
QueryReference<TData, TVariables>,
UseBackgroundQueryResult<TData, TVariables>
];
export function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: BackgroundQueryHookOptionsNoInfer<TData, TVariables>): [QueryRef<TData, TVariables>, UseBackgroundQueryResult<TData, TVariables>];

// @public (undocumented)
export function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken): [undefined, UseBackgroundQueryResult<TData, TVariables>];
Expand All @@ -2018,13 +1901,13 @@ export function useBackgroundQuery<TData = unknown, TVariables extends Operation
export function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (BackgroundQueryHookOptionsNoInfer<TData, TVariables> & {
returnPartialData: true;
})): [
QueryReference<DeepPartial<TData>, TVariables> | undefined,
QueryRef<DeepPartial<TData>, TVariables> | undefined,
UseBackgroundQueryResult<TData, TVariables>
];

// @public (undocumented)
export function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: SkipToken | BackgroundQueryHookOptionsNoInfer<TData, TVariables>): [
QueryReference<TData, TVariables> | undefined,
QueryRef<TData, TVariables> | undefined,
UseBackgroundQueryResult<TData, TVariables>
];

Expand Down Expand Up @@ -2089,7 +1972,7 @@ export function useLoadableQuery<TData = unknown, TVariables extends OperationVa
// @public (undocumented)
export type UseLoadableQueryResult<TData = unknown, TVariables extends OperationVariables = OperationVariables> = [
loadQuery: LoadQueryFunction<TVariables>,
queryRef: QueryReference<TData, TVariables> | null,
queryRef: QueryRef<TData, TVariables> | null,
{
fetchMore: FetchMoreFunction<TData, TVariables>;
refetch: RefetchFunction<TData, TVariables>;
Expand All @@ -2107,7 +1990,7 @@ export function useMutation<TData = any, TVariables = OperationVariables, TConte
export function useQuery<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: QueryHookOptions<NoInfer_2<TData>, NoInfer_2<TVariables>>): QueryResult<TData, TVariables>;

// @public
export function useQueryRefHandlers<TData = unknown, TVariables extends OperationVariables = OperationVariables>(queryRef: QueryReference<TData, TVariables>): UseQueryRefHandlersResult<TData, TVariables>;
export function useQueryRefHandlers<TData = unknown, TVariables extends OperationVariables = OperationVariables>(queryRef: QueryRef<TData, TVariables>): UseQueryRefHandlersResult<TData, TVariables>;

// @public (undocumented)
export interface UseQueryRefHandlersResult<TData = unknown, TVariables extends OperationVariables = OperationVariables> {
Expand All @@ -2121,7 +2004,7 @@ export interface UseQueryRefHandlersResult<TData = unknown, TVariables extends O
export function useReactiveVar<T>(rv: ReactiveVar<T>): T;

// @public (undocumented)
export function useReadQuery<TData>(queryRef: QueryReference<TData>): UseReadQueryResult<TData>;
export function useReadQuery<TData>(queryRef: QueryRef<TData>): UseReadQueryResult<TData>;

// @public (undocumented)
export interface UseReadQueryResult<TData = unknown> {
Expand Down Expand Up @@ -2248,7 +2131,7 @@ interface WatchQueryOptions<TVariables extends OperationVariables = OperationVar
// src/core/watchQueryOptions.ts:269:2 - (ae-forgotten-export) The symbol "UpdateQueryFn" needs to be exported by the entry point index.d.ts
// src/react/hooks/useBackgroundQuery.ts:29:3 - (ae-forgotten-export) The symbol "FetchMoreFunction" needs to be exported by the entry point index.d.ts
// src/react/hooks/useBackgroundQuery.ts:30:3 - (ae-forgotten-export) The symbol "RefetchFunction" needs to be exported by the entry point index.d.ts
// src/react/hooks/useLoadableQuery.ts:106:1 - (ae-forgotten-export) The symbol "ResetFunction" needs to be exported by the entry point index.d.ts
// src/react/hooks/useLoadableQuery.ts:107:1 - (ae-forgotten-export) The symbol "ResetFunction" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down