generated from stijnvanhulle/template
-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/disable use query generation (#1374)
* fix: allow disabling `useQuery` * fix: InfiniteData for react-query v5(disabled for v4) * chore: update examples * chore: upgrade packages * chore: update test cases
- Loading branch information
1 parent
e246cc0
commit 487d135
Showing
60 changed files
with
353 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@kubb/plugin-react-query": patch | ||
"@kubb/plugin-vue-query": patch | ||
--- | ||
|
||
InfiniteData for react-query v5(disabled for v4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@kubb/plugin-react-query": patch | ||
--- | ||
|
||
allow disabling `useQuery` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
examples/react-query/src/gen/hooks/useGetInventorySuspenseHook.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import client from '@kubb/plugin-client/client' | ||
import type { GetInventoryQueryResponse } from '../models/GetInventory.ts' | ||
import type { RequestConfig } from '@kubb/plugin-client/client' | ||
import type { QueryKey, UseSuspenseQueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query' | ||
import { queryOptions, useSuspenseQuery } from '@tanstack/react-query' | ||
|
||
export const getInventorySuspenseQueryKey = () => ['v5', { url: '/store/inventory' }] as const | ||
|
||
export type GetInventorySuspenseQueryKey = ReturnType<typeof getInventorySuspenseQueryKey> | ||
|
||
/** | ||
* @description Returns a map of status codes to quantities | ||
* @summary Returns pet inventories by status | ||
* @link /store/inventory | ||
*/ | ||
async function getInventory(config: Partial<RequestConfig> = {}) { | ||
const res = await client<GetInventoryQueryResponse, Error, unknown>({ method: 'GET', url: '/store/inventory', ...config }) | ||
return res.data | ||
} | ||
|
||
export function getInventorySuspenseQueryOptionsHook(config: Partial<RequestConfig> = {}) { | ||
const queryKey = getInventorySuspenseQueryKey() | ||
return queryOptions({ | ||
queryKey, | ||
queryFn: async ({ signal }) => { | ||
config.signal = signal | ||
return getInventory(config) | ||
}, | ||
}) | ||
} | ||
|
||
/** | ||
* @description Returns a map of status codes to quantities | ||
* @summary Returns pet inventories by status | ||
* @link /store/inventory | ||
*/ | ||
export function useGetInventorySuspenseHook< | ||
TData = GetInventoryQueryResponse, | ||
TQueryData = GetInventoryQueryResponse, | ||
TQueryKey extends QueryKey = GetInventorySuspenseQueryKey, | ||
>( | ||
options: { | ||
query?: Partial<UseSuspenseQueryOptions<GetInventoryQueryResponse, Error, TData, TQueryKey>> | ||
client?: Partial<RequestConfig> | ||
} = {}, | ||
) { | ||
const { query: queryOptions, client: config = {} } = options ?? {} | ||
const queryKey = queryOptions?.queryKey ?? getInventorySuspenseQueryKey() | ||
const query = useSuspenseQuery({ | ||
...(getInventorySuspenseQueryOptionsHook(config) as unknown as UseSuspenseQueryOptions), | ||
queryKey, | ||
...(queryOptions as unknown as Omit<UseSuspenseQueryOptions, 'queryKey'>), | ||
}) as UseSuspenseQueryResult<TData, Error> & { | ||
queryKey: TQueryKey | ||
} | ||
query.queryKey = queryKey as TQueryKey | ||
return query | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.