Skip to content

Commit

Permalink
Provide previousQueryResult through second argument in a type-safe ma…
Browse files Browse the repository at this point in the history
…nner
  • Loading branch information
Cellule committed Feb 3, 2025
1 parent 478c434 commit 0c7af89
Show file tree
Hide file tree
Showing 24 changed files with 485 additions and 308 deletions.
30 changes: 14 additions & 16 deletions .api-reports/api-report-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1733,7 +1733,7 @@ export class ObservableQuery<TData = any, TVariables extends OperationVariables
startPolling(pollInterval: number): void;
stopPolling(): void;
subscribeToMore<TSubscriptionData = TData, TSubscriptionVariables extends OperationVariables = TVariables>(options: SubscribeToMoreOptions<TData, TSubscriptionVariables, TSubscriptionData, TVariables>): () => void;
updateQuery(mapFn: UpdateQueryMapFn<TData, TVariables>, options?: UpdateQueryFnOptions | undefined): void;
updateQuery(mapFn: UpdateQueryMapFn<TData, TVariables>): void;
get variables(): TVariables | undefined;
}

Expand Down Expand Up @@ -2341,8 +2341,6 @@ export interface SubscribeToMoreOptions<TData = any, TSubscriptionVariables exte
// (undocumented)
updateQuery?: SubscribeToMoreUpdateQueryFn<TData, TVariables, TSubscriptionVariables, TSubscriptionData>;
// (undocumented)
updateQueryOptions?: UpdateQueryFnOptions;
// (undocumented)
variables?: TSubscriptionVariables;
}

Expand Down Expand Up @@ -2452,26 +2450,26 @@ type UpdateQueries<TData> = MutationOptions<TData, any, any>["updateQueries"];
// @public (undocumented)
export interface UpdateQueryFn<TData, TVariables extends OperationVariables, TOptions = {}> {
// (undocumented)
(mapFn: UpdateQueryMapFn<TData, TVariables, TOptions>, options?: UpdateQueryFnOptions): void;
}

// @public (undocumented)
export interface UpdateQueryFnOptions {
updateQueryOnPartialPreviousResult?: boolean;
(mapFn: UpdateQueryMapFn<TData, TVariables, TOptions>): void;
}

// @public (undocumented)
export interface UpdateQueryMapFn<TData = any, TVariables extends OperationVariables = OperationVariables, TOptions = {}> {
// (undocumented)
(previousQueryResult: Unmasked<TData>, options: TOptions & UpdateQueryOptions<TVariables>): Unmasked<TData> | undefined;
(
previousQueryResult: Unmasked<TData>, options: TOptions & UpdateQueryOptions<TData, TVariables>): Unmasked<TData> | undefined;
}

// @public (undocumented)
export interface UpdateQueryOptions<TVariables> {
complete: boolean;
// (undocumented)
export type UpdateQueryOptions<TData, TVariables> = {
variables?: TVariables;
}
} & ({
complete: true;
previousQueryResult: Unmasked<TData>;
} | {
complete: false;
previousQueryResult: DeepPartial<Unmasked<TData>> | undefined;
});

// @public (undocumented)
export interface UriFunction {
Expand Down Expand Up @@ -2547,8 +2545,8 @@ interface WriteContext extends ReadMergeModifyContext {
// src/cache/inmemory/policies.ts:162:3 - (ae-forgotten-export) The symbol "KeySpecifier" needs to be exported by the entry point index.d.ts
// src/cache/inmemory/policies.ts:162:3 - (ae-forgotten-export) The symbol "KeyArgsFunction" needs to be exported by the entry point index.d.ts
// src/cache/inmemory/types.ts:139:3 - (ae-forgotten-export) The symbol "KeyFieldsFunction" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:118:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:119:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:119:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:120:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:159:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:414:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/link/http/selectHttpOptionsAndBody.ts:128:32 - (ae-forgotten-export) The symbol "HttpQueryOptions" needs to be exported by the entry point index.d.ts
Expand Down
31 changes: 14 additions & 17 deletions .api-reports/api-report-react.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1437,8 +1437,7 @@ class ObservableQuery<TData = any, TVariables extends OperationVariables = Opera
// Warning: (ae-forgotten-export) The symbol "SubscribeToMoreOptions" needs to be exported by the entry point index.d.ts
subscribeToMore<TSubscriptionData = TData, TSubscriptionVariables extends OperationVariables = TVariables>(options: SubscribeToMoreOptions<TData, TSubscriptionVariables, TSubscriptionData, TVariables>): () => void;
// Warning: (ae-forgotten-export) The symbol "UpdateQueryMapFn" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "UpdateQueryFnOptions" needs to be exported by the entry point index.d.ts
updateQuery(mapFn: UpdateQueryMapFn<TData, TVariables>, options?: UpdateQueryFnOptions | undefined): void;
updateQuery(mapFn: UpdateQueryMapFn<TData, TVariables>): void;
get variables(): TVariables | undefined;
}

Expand Down Expand Up @@ -2116,8 +2115,6 @@ interface SubscribeToMoreOptions<TData = any, TSubscriptionVariables extends Ope
// (undocumented)
updateQuery?: SubscribeToMoreUpdateQueryFn<TData, TVariables, TSubscriptionVariables, TSubscriptionData>;
// (undocumented)
updateQueryOptions?: UpdateQueryFnOptions;
// (undocumented)
variables?: TSubscriptionVariables;
}

Expand Down Expand Up @@ -2250,28 +2247,28 @@ type UpdateQueries<TData> = MutationOptions<TData, any, any>["updateQueries"];
// @public (undocumented)
interface UpdateQueryFn<TData, TVariables extends OperationVariables, TOptions = {}> {
// (undocumented)
(mapFn: UpdateQueryMapFn<TData, TVariables, TOptions>, options?: UpdateQueryFnOptions): void;
}

// @public (undocumented)
interface UpdateQueryFnOptions {
updateQueryOnPartialPreviousResult?: boolean;
(mapFn: UpdateQueryMapFn<TData, TVariables, TOptions>): void;
}

// @public (undocumented)
interface UpdateQueryMapFn<TData = any, TVariables extends OperationVariables = OperationVariables, TOptions = {}> {
// Warning: (ae-forgotten-export) The symbol "UpdateQueryOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
(previousQueryResult: Unmasked<TData>, options: TOptions & UpdateQueryOptions<TVariables>): Unmasked<TData> | undefined;
(
previousQueryResult: Unmasked<TData>, options: TOptions & UpdateQueryOptions<TData, TVariables>): Unmasked<TData> | undefined;
}

// @public (undocumented)
interface UpdateQueryOptions<TVariables> {
complete: boolean;
// (undocumented)
type UpdateQueryOptions<TData, TVariables> = {
variables?: TVariables;
}
} & ({
complete: true;
previousQueryResult: Unmasked<TData>;
} | {
complete: false;
previousQueryResult: DeepPartial<Unmasked<TData>> | undefined;
});

// @public (undocumented)
interface UriFunction {
Expand Down Expand Up @@ -2568,8 +2565,8 @@ interface WatchQueryOptions<TVariables extends OperationVariables = OperationVar
// src/cache/core/types/common.ts:104:3 - (ae-forgotten-export) The symbol "ToReferenceFunction" needs to be exported by the entry point index.d.ts
// src/cache/core/types/common.ts:105:3 - (ae-forgotten-export) The symbol "StorageType" needs to be exported by the entry point index.d.ts
// src/core/LocalState.ts:46:5 - (ae-forgotten-export) The symbol "FragmentMap" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:118:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:119:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:119:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:120:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:159:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:414:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/types.ts:175:3 - (ae-forgotten-export) The symbol "MutationQueryReducer" needs to be exported by the entry point index.d.ts
Expand Down
31 changes: 14 additions & 17 deletions .api-reports/api-report-react_components.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1315,8 +1315,7 @@ class ObservableQuery<TData = any, TVariables extends OperationVariables = Opera
// Warning: (ae-forgotten-export) The symbol "SubscribeToMoreOptions" needs to be exported by the entry point index.d.ts
subscribeToMore<TSubscriptionData = TData, TSubscriptionVariables extends OperationVariables = TVariables>(options: SubscribeToMoreOptions<TData, TSubscriptionVariables, TSubscriptionData, TVariables>): () => void;
// Warning: (ae-forgotten-export) The symbol "UpdateQueryMapFn" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "UpdateQueryFnOptions" needs to be exported by the entry point index.d.ts
updateQuery(mapFn: UpdateQueryMapFn<TData, TVariables>, options?: UpdateQueryFnOptions | undefined): void;
updateQuery(mapFn: UpdateQueryMapFn<TData, TVariables>): void;
get variables(): TVariables | undefined;
}

Expand Down Expand Up @@ -1867,8 +1866,6 @@ interface SubscribeToMoreOptions<TData = any, TSubscriptionVariables extends Ope
// (undocumented)
updateQuery?: SubscribeToMoreUpdateQueryFn<TData, TVariables, TSubscriptionVariables, TSubscriptionData>;
// (undocumented)
updateQueryOptions?: UpdateQueryFnOptions;
// (undocumented)
variables?: TSubscriptionVariables;
}

Expand Down Expand Up @@ -1986,28 +1983,28 @@ type UpdateQueries<TData> = MutationOptions<TData, any, any>["updateQueries"];
// @public (undocumented)
interface UpdateQueryFn<TData, TVariables extends OperationVariables, TOptions = {}> {
// (undocumented)
(mapFn: UpdateQueryMapFn<TData, TVariables, TOptions>, options?: UpdateQueryFnOptions): void;
}

// @public (undocumented)
interface UpdateQueryFnOptions {
updateQueryOnPartialPreviousResult?: boolean;
(mapFn: UpdateQueryMapFn<TData, TVariables, TOptions>): void;
}

// @public (undocumented)
interface UpdateQueryMapFn<TData = any, TVariables extends OperationVariables = OperationVariables, TOptions = {}> {
// Warning: (ae-forgotten-export) The symbol "UpdateQueryOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
(previousQueryResult: Unmasked<TData>, options: TOptions & UpdateQueryOptions<TVariables>): Unmasked<TData> | undefined;
(
previousQueryResult: Unmasked<TData>, options: TOptions & UpdateQueryOptions<TData, TVariables>): Unmasked<TData> | undefined;
}

// @public (undocumented)
interface UpdateQueryOptions<TVariables> {
complete: boolean;
// (undocumented)
type UpdateQueryOptions<TData, TVariables> = {
variables?: TVariables;
}
} & ({
complete: true;
previousQueryResult: Unmasked<TData>;
} | {
complete: false;
previousQueryResult: DeepPartial<Unmasked<TData>> | undefined;
});

// @public (undocumented)
interface UriFunction {
Expand Down Expand Up @@ -2053,8 +2050,8 @@ interface WatchQueryOptions<TVariables extends OperationVariables = OperationVar
// src/cache/core/types/common.ts:104:3 - (ae-forgotten-export) The symbol "ToReferenceFunction" needs to be exported by the entry point index.d.ts
// src/cache/core/types/common.ts:105:3 - (ae-forgotten-export) The symbol "StorageType" needs to be exported by the entry point index.d.ts
// src/core/LocalState.ts:46:5 - (ae-forgotten-export) The symbol "FragmentMap" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:118:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:119:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:119:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:120:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:159:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:414:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/types.ts:175:3 - (ae-forgotten-export) The symbol "MutationQueryReducer" needs to be exported by the entry point index.d.ts
Expand Down
31 changes: 14 additions & 17 deletions .api-reports/api-report-react_context.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1268,8 +1268,7 @@ class ObservableQuery<TData = any, TVariables extends OperationVariables = Opera
// Warning: (ae-forgotten-export) The symbol "SubscribeToMoreOptions" needs to be exported by the entry point index.d.ts
subscribeToMore<TSubscriptionData = TData, TSubscriptionVariables extends OperationVariables = TVariables>(options: SubscribeToMoreOptions<TData, TSubscriptionVariables, TSubscriptionData, TVariables>): () => void;
// Warning: (ae-forgotten-export) The symbol "UpdateQueryMapFn" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "UpdateQueryFnOptions" needs to be exported by the entry point index.d.ts
updateQuery(mapFn: UpdateQueryMapFn<TData, TVariables>, options?: UpdateQueryFnOptions | undefined): void;
updateQuery(mapFn: UpdateQueryMapFn<TData, TVariables>): void;
get variables(): TVariables | undefined;
}

Expand Down Expand Up @@ -1819,8 +1818,6 @@ interface SubscribeToMoreOptions<TData = any, TSubscriptionVariables extends Ope
// (undocumented)
updateQuery?: SubscribeToMoreUpdateQueryFn<TData, TVariables, TSubscriptionVariables, TSubscriptionData>;
// (undocumented)
updateQueryOptions?: UpdateQueryFnOptions;
// (undocumented)
variables?: TSubscriptionVariables;
}

Expand Down Expand Up @@ -1905,28 +1902,28 @@ type UpdateQueries<TData> = MutationOptions<TData, any, any>["updateQueries"];
// @public (undocumented)
interface UpdateQueryFn<TData, TVariables extends OperationVariables, TOptions = {}> {
// (undocumented)
(mapFn: UpdateQueryMapFn<TData, TVariables, TOptions>, options?: UpdateQueryFnOptions): void;
}

// @public (undocumented)
interface UpdateQueryFnOptions {
updateQueryOnPartialPreviousResult?: boolean;
(mapFn: UpdateQueryMapFn<TData, TVariables, TOptions>): void;
}

// @public (undocumented)
interface UpdateQueryMapFn<TData = any, TVariables extends OperationVariables = OperationVariables, TOptions = {}> {
// Warning: (ae-forgotten-export) The symbol "UpdateQueryOptions" needs to be exported by the entry point index.d.ts
//
// (undocumented)
(previousQueryResult: Unmasked<TData>, options: TOptions & UpdateQueryOptions<TVariables>): Unmasked<TData> | undefined;
(
previousQueryResult: Unmasked<TData>, options: TOptions & UpdateQueryOptions<TData, TVariables>): Unmasked<TData> | undefined;
}

// @public (undocumented)
interface UpdateQueryOptions<TVariables> {
complete: boolean;
// (undocumented)
type UpdateQueryOptions<TData, TVariables> = {
variables?: TVariables;
}
} & ({
complete: true;
previousQueryResult: Unmasked<TData>;
} | {
complete: false;
previousQueryResult: DeepPartial<Unmasked<TData>> | undefined;
});

// @public (undocumented)
interface UriFunction {
Expand Down Expand Up @@ -1972,8 +1969,8 @@ interface WatchQueryOptions<TVariables extends OperationVariables = OperationVar
// src/cache/core/types/common.ts:104:3 - (ae-forgotten-export) The symbol "ToReferenceFunction" needs to be exported by the entry point index.d.ts
// src/cache/core/types/common.ts:105:3 - (ae-forgotten-export) The symbol "StorageType" needs to be exported by the entry point index.d.ts
// src/core/LocalState.ts:46:5 - (ae-forgotten-export) The symbol "FragmentMap" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:118:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:119:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:119:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:120:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:159:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:414:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/types.ts:175:3 - (ae-forgotten-export) The symbol "MutationQueryReducer" needs to be exported by the entry point index.d.ts
Expand Down
Loading

0 comments on commit 0c7af89

Please sign in to comment.