From 1aff031e1f25cface213b5131b2116d7e8c6ef19 Mon Sep 17 00:00:00 2001 From: Melloware Date: Fri, 9 Feb 2024 12:46:04 -0500 Subject: [PATCH] fix: useQuery improve override logic (#1212) --- packages/query/src/index.ts | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/packages/query/src/index.ts b/packages/query/src/index.ts index f02f2124b..4a44a1f05 100644 --- a/packages/query/src/index.ts +++ b/packages/query/src/index.ts @@ -1140,16 +1140,24 @@ const generateQueryHook = async ( let implementation = ''; let mutators = undefined; - const isQuery = - (Verbs.GET === verb && - (override.query.useQuery || - override.query.useSuspenseQuery || - override.query.useInfinite || - override.query.useSuspenseInfiniteQuery)) || - operationQueryOptions?.useInfinite || - operationQueryOptions?.useSuspenseInfiniteQuery || - operationQueryOptions?.useQuery || - operationQueryOptions?.useSuspenseQuery; + let isQuery = + Verbs.GET === verb && + (override.query.useQuery || + override.query.useSuspenseQuery || + override.query.useInfinite || + override.query.useSuspenseInfiniteQuery); + if (operationQueryOptions?.useInfinite !== undefined) { + isQuery = operationQueryOptions.useInfinite; + } + if (operationQueryOptions?.useSuspenseInfiniteQuery !== undefined) { + isQuery = operationQueryOptions.useSuspenseInfiniteQuery; + } + if (operationQueryOptions?.useQuery !== undefined) { + isQuery = operationQueryOptions.useQuery; + } + if (operationQueryOptions?.useSuspenseQuery !== undefined) { + isQuery = operationQueryOptions.useSuspenseQuery; + } if (isQuery) { const queryKeyMutator = query.queryKey