Skip to content

Commit cdcaad4

Browse files
committed
refactor: complete MaybePromise<T> migration and update mutation callback return types
- Convert remaining T | Promise<T> patterns to MaybePromise<T> in streamedQuery and mutation options - Update mutation callback return types from MaybePromise<void> to MaybePromise<unknown> to mirror #9251
1 parent a262982 commit cdcaad4

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

packages/query-core/src/mutationCache.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,24 @@ interface MutationCacheConfig {
2121
variables: unknown,
2222
context: unknown,
2323
mutation: Mutation<unknown, unknown, unknown>,
24-
) => MaybePromise<void>
24+
) => MaybePromise<unknown>
2525
onSuccess?: (
2626
data: unknown,
2727
variables: unknown,
2828
context: unknown,
2929
mutation: Mutation<unknown, unknown, unknown>,
30-
) => MaybePromise<void>
30+
) => MaybePromise<unknown>
3131
onMutate?: (
3232
variables: unknown,
3333
mutation: Mutation<unknown, unknown, unknown>,
34-
) => MaybePromise<void>
34+
) => MaybePromise<unknown>
3535
onSettled?: (
3636
data: unknown | undefined,
3737
error: DefaultError | null,
3838
variables: unknown,
3939
context: unknown,
4040
mutation: Mutation<unknown, unknown, unknown>,
41-
) => MaybePromise<void>
41+
) => MaybePromise<unknown>
4242
}
4343

4444
interface NotifyEventMutationAdded extends NotifyEvent {

packages/query-core/src/streamedQuery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { addToEnd } from './utils'
2-
import type { QueryFunction, QueryFunctionContext, QueryKey } from './types'
2+
import type { MaybePromise, QueryFunction, QueryFunctionContext, QueryKey } from './types'
33

44
/**
55
* This is a helper function to create a query function that streams data from an AsyncIterable.
@@ -26,7 +26,7 @@ export function streamedQuery<
2626
}: {
2727
queryFn: (
2828
context: QueryFunctionContext<TQueryKey>,
29-
) => AsyncIterable<TQueryFnData> | Promise<AsyncIterable<TQueryFnData>>
29+
) => MaybePromise<AsyncIterable<TQueryFnData>>
3030
refetchMode?: 'append' | 'reset' | 'replace'
3131
maxChunks?: number
3232
}): QueryFunction<Array<TQueryFnData>, TQueryKey> {

packages/query-core/src/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,23 +1102,23 @@ export interface MutationOptions<
11021102
mutationKey?: MutationKey
11031103
onMutate?: (
11041104
variables: TVariables,
1105-
) => Promise<TContext | undefined> | TContext | undefined
1105+
) => MaybePromise<TContext | undefined>
11061106
onSuccess?: (
11071107
data: TData,
11081108
variables: TVariables,
11091109
context: TContext,
1110-
) => MaybePromise<void>
1110+
) => MaybePromise<unknown>
11111111
onError?: (
11121112
error: TError,
11131113
variables: TVariables,
11141114
context: TContext | undefined,
1115-
) => MaybePromise<void>
1115+
) => MaybePromise<unknown>
11161116
onSettled?: (
11171117
data: TData | undefined,
11181118
error: TError | null,
11191119
variables: TVariables,
11201120
context: TContext | undefined,
1121-
) => MaybePromise<void>
1121+
) => MaybePromise<unknown>
11221122
retry?: RetryValue<TError>
11231123
retryDelay?: RetryDelayValue<TError>
11241124
networkMode?: NetworkMode

0 commit comments

Comments
 (0)