Skip to content

Commit 63220a0

Browse files
committed
fix type issues
1 parent 38d32cc commit 63220a0

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/builder/MutationBuilder.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ export class MutationBuilderFrozen<T extends BuilderTypeTemplate> {
5151
meta,
5252
) => {
5353
return async (vars) => {
54+
const queryKey = [this.mergeVars([this.config.vars, vars])] as [T['vars']];
5455
return this.config.queryFn({
55-
queryKey: [this.mergeVars([this.config.vars, vars])],
56+
queryKey,
5657
meta,
5758
client: this.config.queryClient || queryClient,
5859
signal: new AbortController().signal,
60+
originalQueryKey: queryKey,
5961
});
6062
};
6163
};

src/builder/createUpdateMiddleware.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ type CreateUpdateMiddleware = <T extends BuilderTypeTemplate>(
1111

1212
export const createUpdateMiddleware: CreateUpdateMiddleware = (tags) =>
1313
async function updateMiddleware(ctx, next, throwError, config) {
14+
type TagObj = QueryUpdateTagObject<any, any, any, any>;
15+
type TagCtx = QueryTagContext<any>;
16+
1417
let undos: UpdateTagsUndoer[] | null = null;
15-
const invalidates: QueryUpdateTagObject[] = [];
16-
const optCtx: QueryTagContext<unknown> = { client: ctx.client, vars: ctx.vars, data: undefined };
18+
const invalidates: TagObj[] = [];
19+
const optCtx: TagCtx = { client: ctx.client, vars: ctx.vars, data: undefined };
1720

1821
try {
19-
const optUpdates = resolveTags<any, QueryUpdateTagObject>({ tags, ...optCtx }).filter((u) => u.optimistic);
22+
const optUpdates = resolveTags<any, TagObj>({ tags, ...optCtx }).filter((u) => u.optimistic);
2023
undos = updateTags({
2124
queryClient: ctx.client,
2225
tags: optUpdates.filter((x) => x.updater),
@@ -30,17 +33,17 @@ export const createUpdateMiddleware: CreateUpdateMiddleware = (tags) =>
3033

3134
const data = await next(ctx);
3235

33-
const pesCtx: QueryTagContext<unknown> = { ...optCtx, data };
34-
const pesUpdates = resolveTags<any, QueryUpdateTagObject>({ tags, ...pesCtx }).filter((u) => !u.optimistic);
36+
const pesCtx: TagCtx = { ...optCtx, data };
37+
const pesUpdates = resolveTags<any, TagObj>({ tags, ...pesCtx }).filter((u) => !u.optimistic);
3538
updateTags({ queryClient: ctx.client, tags: pesUpdates.filter((x) => x.updater), ctx: pesCtx });
3639
invalidates.push(...pesUpdates);
3740

3841
return data;
3942
} catch (error) {
4043
if (undos?.length) undoUpdateTags(undos, ctx.client);
4144

42-
const pesCtx: QueryTagContext<unknown> = { ...optCtx, error };
43-
const pesUpdates = resolveTags<any, QueryUpdateTagObject>({ tags, ...pesCtx }).filter((u) => !u.optimistic);
45+
const pesCtx: TagCtx = { ...optCtx, error };
46+
const pesUpdates = resolveTags<any, TagObj>({ tags, ...pesCtx }).filter((u) => !u.optimistic);
4447
invalidates.push(...pesUpdates);
4548

4649
throw error;

src/tags/updateTags.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function updateTags({
1616
ctx,
1717
optimistic,
1818
}: {
19-
tags: readonly QueryUpdateTag[];
19+
tags: readonly QueryUpdateTag<any, any, any>[];
2020
queryClient: QueryClient;
2121
ctx: QueryTagContext<unknown>;
2222
optimistic?: boolean;

0 commit comments

Comments
 (0)