Skip to content

Commit 35a6400

Browse files
Frank-IIIAmp
andcommitted
fix: align queryKey type signatures to accept body for POST key differentiation
Amp-Thread-ID: https://ampcode.com/threads/T-019d5b33-0efe-70aa-aa9a-2d71dd53968c Co-authored-by: Amp <amp@ampcode.com>
1 parent 5682592 commit 35a6400

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ function createMethodDecorator(ctx: ProxyContext, paths: string[], method: strin
171171
fn.queryKey = (input?: {
172172
params?: Record<string, string | number>;
173173
query?: unknown;
174+
body?: unknown;
174175
}): QueryKey => {
175176
return buildQueryKey(ctx.prefix, method, pathTemplate, input);
176177
};

src/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ type TQMethodParam<Body, Headers, Query, Params> = MaybeEmptyObject<Headers, "he
181181
TQParamBase;
182182

183183
type OmitQueryInput<T> = Omit<T, "body" | "headers" | "fetch">;
184+
type OmitQueryKeyInput<T> = Omit<T, "headers" | "fetch">;
184185

185186
type EdenMethodBaseQueryKey<Params, Query> = readonly [
186187
...QueryKey,
@@ -296,7 +297,7 @@ export interface EdenTQMethod<Body, Headers, Query, Params, Res> {
296297
): Promise<EdenRawResponse<Res>>;
297298

298299
queryKey(
299-
input?: OmitQueryInput<TQMethodParam<Body, Headers, Query, Params>>,
300+
input?: OmitQueryKeyInput<TQMethodParam<Body, Headers, Query, Params>>,
300301
): EdenMethodQueryKey<Params, Query, Res>;
301302

302303
queryOptions<TData = ExtractData<Res>>(
@@ -438,7 +439,7 @@ export namespace EdenTQ {
438439

439440
export interface EdenTQUtilsMethod<Body, Headers, Query, Params, Res> {
440441
queryKey(
441-
input?: OmitQueryInput<TQMethodParam<Body, Headers, Query, Params>>,
442+
input?: OmitQueryKeyInput<TQMethodParam<Body, Headers, Query, Params>>,
442443
): EdenMethodQueryKey<Params, Query, Res>;
443444

444445
queryOptions<TData = ExtractData<Res>>(

0 commit comments

Comments
 (0)