@kubb/plugin-react-query 5.0.0-alpha.9 → 5.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +17 -10
- package/README.md +1 -3
- package/dist/components-DTGLu4UV.js +1451 -0
- package/dist/components-DTGLu4UV.js.map +1 -0
- package/dist/components-dAKJEn9b.cjs +1571 -0
- package/dist/components-dAKJEn9b.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +105 -161
- package/dist/components.js +1 -1
- package/dist/generators-CWEQsdO9.cjs +1502 -0
- package/dist/generators-CWEQsdO9.cjs.map +1 -0
- package/dist/generators-C_fbcjpG.js +1460 -0
- package/dist/generators-C_fbcjpG.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +9 -505
- package/dist/generators.js +1 -1
- package/dist/index.cjs +114 -126
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +110 -126
- package/dist/index.js.map +1 -1
- package/dist/{types-D5S7Ny9r.d.ts → types-DfaFRSBf.d.ts} +100 -86
- package/extension.yaml +938 -0
- package/package.json +59 -62
- package/src/components/InfiniteQuery.tsx +75 -139
- package/src/components/InfiniteQueryOptions.tsx +62 -164
- package/src/components/Mutation.tsx +58 -113
- package/src/components/MutationOptions.tsx +61 -80
- package/src/components/Query.tsx +67 -140
- package/src/components/QueryOptions.tsx +75 -135
- package/src/components/SuspenseInfiniteQuery.tsx +75 -139
- package/src/components/SuspenseInfiniteQueryOptions.tsx +62 -164
- package/src/components/SuspenseQuery.tsx +67 -150
- package/src/generators/customHookOptionsFileGenerator.tsx +33 -45
- package/src/generators/hookOptionsGenerator.tsx +115 -175
- package/src/generators/infiniteQueryGenerator.tsx +183 -176
- package/src/generators/mutationGenerator.tsx +127 -138
- package/src/generators/queryGenerator.tsx +141 -141
- package/src/generators/suspenseInfiniteQueryGenerator.tsx +175 -155
- package/src/generators/suspenseQueryGenerator.tsx +149 -148
- package/src/index.ts +1 -1
- package/src/plugin.ts +133 -183
- package/src/resolvers/resolverReactQuery.ts +22 -0
- package/src/types.ts +67 -45
- package/src/utils.ts +40 -0
- package/dist/components-BHQT9ZLc.cjs +0 -1634
- package/dist/components-BHQT9ZLc.cjs.map +0 -1
- package/dist/components-CpyHYGOw.js +0 -1520
- package/dist/components-CpyHYGOw.js.map +0 -1
- package/dist/generators-DP07m3rH.cjs +0 -1469
- package/dist/generators-DP07m3rH.cjs.map +0 -1
- package/dist/generators-DkQwKTc2.js +0 -1427
- package/dist/generators-DkQwKTc2.js.map +0 -1
|
@@ -1,35 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import type { FabricReactNode, Params } from '@kubb/react-fabric/types'
|
|
1
|
+
import { ast } from '@kubb/core'
|
|
2
|
+
import type { ResolverTs } from '@kubb/plugin-ts'
|
|
3
|
+
import { functionPrinter } from '@kubb/plugin-ts'
|
|
4
|
+
import { File, Function } from '@kubb/renderer-jsx'
|
|
5
|
+
import type { KubbReactNode } from '@kubb/renderer-jsx/types'
|
|
7
6
|
import type { PluginReactQuery } from '../types.ts'
|
|
8
|
-
import {
|
|
7
|
+
import { buildMutationArgParams, resolveErrorNames } from '../utils.ts'
|
|
9
8
|
|
|
10
9
|
type Props = {
|
|
11
10
|
name: string
|
|
12
11
|
clientName: string
|
|
13
12
|
mutationKeyName: string
|
|
14
|
-
|
|
13
|
+
node: ast.OperationNode
|
|
14
|
+
tsResolver: ResolverTs
|
|
15
15
|
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
16
16
|
paramsType: PluginReactQuery['resolvedOptions']['paramsType']
|
|
17
17
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
|
|
18
18
|
dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
21
|
+
const declarationPrinter = functionPrinter({ mode: 'declaration' })
|
|
22
|
+
const callPrinter = functionPrinter({ mode: 'call' })
|
|
23
|
+
const keysPrinter = functionPrinter({ mode: 'keys' })
|
|
24
24
|
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
: '
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
function getConfigParam(node: ast.OperationNode, resolver: ResolverTs): ast.FunctionParametersNode {
|
|
26
|
+
const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : undefined
|
|
27
|
+
return ast.createFunctionParameters({
|
|
28
|
+
params: [
|
|
29
|
+
ast.createFunctionParameter({
|
|
30
|
+
name: 'config',
|
|
31
|
+
type: ast.createParamsType({
|
|
32
|
+
variant: 'reference',
|
|
33
|
+
name: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : 'Partial<RequestConfig> & { client?: Client }',
|
|
34
|
+
}),
|
|
35
|
+
default: '{}',
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
33
38
|
})
|
|
34
39
|
}
|
|
35
40
|
|
|
@@ -37,80 +42,56 @@ export function MutationOptions({
|
|
|
37
42
|
name,
|
|
38
43
|
clientName,
|
|
39
44
|
dataReturnType,
|
|
40
|
-
|
|
45
|
+
node,
|
|
46
|
+
tsResolver,
|
|
41
47
|
paramsCasing,
|
|
42
48
|
paramsType,
|
|
43
49
|
pathParamsType,
|
|
44
50
|
mutationKeyName,
|
|
45
|
-
}: Props):
|
|
46
|
-
const
|
|
47
|
-
const TData = dataReturnType === 'data' ?
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const clientParams = Client.getParams({
|
|
51
|
-
typeSchemas,
|
|
52
|
-
paramsCasing,
|
|
53
|
-
paramsType,
|
|
54
|
-
pathParamsType,
|
|
55
|
-
isConfigurable: true,
|
|
56
|
-
})
|
|
51
|
+
}: Props): KubbReactNode {
|
|
52
|
+
const responseName = tsResolver.resolveResponseName(node)
|
|
53
|
+
const TData = dataReturnType === 'data' ? responseName : `ResponseConfig<${responseName}>`
|
|
54
|
+
const errorNames = resolveErrorNames(node, tsResolver)
|
|
55
|
+
const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(' | ') : 'Error'}>`
|
|
57
56
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
typeSchemas,
|
|
61
|
-
})
|
|
57
|
+
const configParamsNode = getConfigParam(node, tsResolver)
|
|
58
|
+
const paramsSignature = declarationPrinter.print(configParamsNode) ?? ''
|
|
62
59
|
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
data: typeSchemas.request?.name
|
|
66
|
-
? {
|
|
67
|
-
type: typeSchemas.request?.name,
|
|
68
|
-
optional: isOptional(typeSchemas.request?.schema),
|
|
69
|
-
}
|
|
70
|
-
: undefined,
|
|
71
|
-
params: typeSchemas.queryParams?.name
|
|
72
|
-
? {
|
|
73
|
-
type: typeSchemas.queryParams?.name,
|
|
74
|
-
optional: isOptional(typeSchemas.queryParams?.schema),
|
|
75
|
-
}
|
|
76
|
-
: undefined,
|
|
77
|
-
headers: typeSchemas.headerParams?.name
|
|
78
|
-
? {
|
|
79
|
-
type: typeSchemas.headerParams?.name,
|
|
80
|
-
optional: isOptional(typeSchemas.headerParams?.schema),
|
|
81
|
-
}
|
|
82
|
-
: undefined,
|
|
83
|
-
})
|
|
60
|
+
const mutationArgParamsNode = buildMutationArgParams(node, { paramsCasing, resolver: tsResolver })
|
|
61
|
+
const hasMutationParams = mutationArgParamsNode.params.length > 0
|
|
84
62
|
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
// No use of pathParams because useMutation can only take one argument in object form,
|
|
88
|
-
// see https://tanstack.com/query/latest/docs/framework/react/reference/useMutation#usemutation
|
|
89
|
-
mode: 'object',
|
|
90
|
-
children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
|
|
91
|
-
if (value) {
|
|
92
|
-
acc[key] = {
|
|
93
|
-
...value,
|
|
94
|
-
type: undefined,
|
|
95
|
-
}
|
|
96
|
-
}
|
|
63
|
+
const TRequest = hasMutationParams ? (declarationPrinter.print(mutationArgParamsNode) ?? '') : ''
|
|
64
|
+
const argKeysStr = hasMutationParams ? (keysPrinter.print(mutationArgParamsNode) ?? '') : ''
|
|
97
65
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
66
|
+
const clientCallParamsNode = ast.createOperationParams(node, {
|
|
67
|
+
paramsType,
|
|
68
|
+
pathParamsType: paramsType === 'object' ? 'object' : pathParamsType === 'object' ? 'object' : 'inline',
|
|
69
|
+
paramsCasing,
|
|
70
|
+
resolver: tsResolver,
|
|
71
|
+
extraParams: [
|
|
72
|
+
ast.createFunctionParameter({
|
|
73
|
+
name: 'config',
|
|
74
|
+
type: ast.createParamsType({
|
|
75
|
+
variant: 'reference',
|
|
76
|
+
name: node.requestBody?.content?.[0]?.schema
|
|
77
|
+
? `Partial<RequestConfig<${tsResolver.resolveDataName(node)}>> & { client?: Client }`
|
|
78
|
+
: 'Partial<RequestConfig> & { client?: Client }',
|
|
79
|
+
}),
|
|
80
|
+
default: '{}',
|
|
81
|
+
}),
|
|
82
|
+
],
|
|
101
83
|
})
|
|
102
|
-
|
|
103
|
-
const TRequest = mutationParams.toConstructor()
|
|
84
|
+
const clientCallStr = callPrinter.print(clientCallParamsNode) ?? ''
|
|
104
85
|
|
|
105
86
|
return (
|
|
106
87
|
<File.Source name={name} isExportable isIndexable>
|
|
107
|
-
<Function name={name} export params={
|
|
88
|
+
<Function name={name} export params={paramsSignature} generics={['TContext = unknown']}>
|
|
108
89
|
{`
|
|
109
|
-
const mutationKey = ${mutationKeyName}(
|
|
110
|
-
return mutationOptions<${TData},
|
|
90
|
+
const mutationKey = ${mutationKeyName}()
|
|
91
|
+
return mutationOptions<${TData}, ${TError}, ${TRequest ? `{${TRequest}}` : 'void'}, TContext>({
|
|
111
92
|
mutationKey,
|
|
112
|
-
mutationFn: async(${
|
|
113
|
-
return ${clientName}(${
|
|
93
|
+
mutationFn: async(${hasMutationParams ? `{ ${argKeysStr} }` : '_'}) => {
|
|
94
|
+
return ${clientName}(${clientCallStr})
|
|
114
95
|
},
|
|
115
96
|
})
|
|
116
97
|
`}
|
|
@@ -119,4 +100,4 @@ export function MutationOptions({
|
|
|
119
100
|
)
|
|
120
101
|
}
|
|
121
102
|
|
|
122
|
-
MutationOptions.getParams =
|
|
103
|
+
MutationOptions.getParams = getConfigParam
|
package/src/components/Query.tsx
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
4
|
-
import { File, Function
|
|
5
|
-
import type {
|
|
1
|
+
import { ast } from '@kubb/core'
|
|
2
|
+
import type { ResolverTs } from '@kubb/plugin-ts'
|
|
3
|
+
import { functionPrinter } from '@kubb/plugin-ts'
|
|
4
|
+
import { File, Function } from '@kubb/renderer-jsx'
|
|
5
|
+
import type { KubbReactNode } from '@kubb/renderer-jsx/types'
|
|
6
6
|
import type { PluginReactQuery } from '../types.ts'
|
|
7
|
+
import { getComments, resolveErrorNames } from '../utils.ts'
|
|
7
8
|
import { QueryKey } from './QueryKey.tsx'
|
|
8
|
-
import {
|
|
9
|
+
import { getQueryOptionsParams } from './QueryOptions.tsx'
|
|
9
10
|
|
|
10
11
|
type Props = {
|
|
11
|
-
/**
|
|
12
|
-
* Name of the function
|
|
13
|
-
*/
|
|
14
12
|
name: string
|
|
15
13
|
queryOptionsName: string
|
|
16
14
|
queryKeyName: string
|
|
17
15
|
queryKeyTypeName: string
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
node: ast.OperationNode
|
|
17
|
+
tsResolver: ResolverTs
|
|
20
18
|
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
21
19
|
paramsType: PluginReactQuery['resolvedOptions']['paramsType']
|
|
22
20
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
|
|
@@ -24,99 +22,45 @@ type Props = {
|
|
|
24
22
|
customOptions: PluginReactQuery['resolvedOptions']['customOptions']
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
optional: isOptional(typeSchemas.queryParams?.schema),
|
|
54
|
-
}
|
|
55
|
-
: undefined,
|
|
56
|
-
headers: typeSchemas.headerParams?.name
|
|
57
|
-
? {
|
|
58
|
-
type: typeSchemas.headerParams?.name,
|
|
59
|
-
optional: isOptional(typeSchemas.headerParams?.schema),
|
|
60
|
-
}
|
|
61
|
-
: undefined,
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Check if all children are optional or undefined
|
|
65
|
-
const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional)
|
|
66
|
-
|
|
67
|
-
return FunctionParams.factory({
|
|
68
|
-
data: {
|
|
69
|
-
mode: 'object',
|
|
70
|
-
children,
|
|
71
|
-
default: allChildrenAreOptional ? '{}' : undefined,
|
|
72
|
-
},
|
|
73
|
-
options: {
|
|
74
|
-
type: `
|
|
75
|
-
{
|
|
25
|
+
const declarationPrinter = functionPrinter({ mode: 'declaration' })
|
|
26
|
+
const callPrinter = functionPrinter({ mode: 'call' })
|
|
27
|
+
|
|
28
|
+
function getParams(
|
|
29
|
+
node: ast.OperationNode,
|
|
30
|
+
options: {
|
|
31
|
+
paramsType: PluginReactQuery['resolvedOptions']['paramsType']
|
|
32
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
33
|
+
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
|
|
34
|
+
dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
|
|
35
|
+
resolver: ResolverTs
|
|
36
|
+
},
|
|
37
|
+
): ast.FunctionParametersNode {
|
|
38
|
+
const { paramsType, paramsCasing, pathParamsType, dataReturnType, resolver } = options
|
|
39
|
+
const responseName = resolver.resolveResponseName(node)
|
|
40
|
+
const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : undefined
|
|
41
|
+
const errorNames = resolveErrorNames(node, resolver)
|
|
42
|
+
|
|
43
|
+
const TData = dataReturnType === 'data' ? responseName : `ResponseConfig<${responseName}>`
|
|
44
|
+
const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(' | ') : 'Error'}>`
|
|
45
|
+
|
|
46
|
+
const optionsParam = ast.createFunctionParameter({
|
|
47
|
+
name: 'options',
|
|
48
|
+
type: ast.createParamsType({
|
|
49
|
+
variant: 'reference',
|
|
50
|
+
name: `{
|
|
76
51
|
query?: Partial<QueryObserverOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },
|
|
77
|
-
client?: ${
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
90
|
-
default: isAllOptional(typeSchemas.pathParams?.schema) ? '{}' : undefined,
|
|
91
|
-
}
|
|
92
|
-
: undefined,
|
|
93
|
-
data: typeSchemas.request?.name
|
|
94
|
-
? {
|
|
95
|
-
type: typeSchemas.request?.name,
|
|
96
|
-
optional: isOptional(typeSchemas.request?.schema),
|
|
97
|
-
}
|
|
98
|
-
: undefined,
|
|
99
|
-
params: typeSchemas.queryParams?.name
|
|
100
|
-
? {
|
|
101
|
-
type: typeSchemas.queryParams?.name,
|
|
102
|
-
optional: isOptional(typeSchemas.queryParams?.schema),
|
|
103
|
-
}
|
|
104
|
-
: undefined,
|
|
105
|
-
headers: typeSchemas.headerParams?.name
|
|
106
|
-
? {
|
|
107
|
-
type: typeSchemas.headerParams?.name,
|
|
108
|
-
optional: isOptional(typeSchemas.headerParams?.schema),
|
|
109
|
-
}
|
|
110
|
-
: undefined,
|
|
111
|
-
options: {
|
|
112
|
-
type: `
|
|
113
|
-
{
|
|
114
|
-
query?: Partial<QueryObserverOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },
|
|
115
|
-
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : 'Partial<RequestConfig> & { client?: Client }'}
|
|
116
|
-
}
|
|
117
|
-
`,
|
|
118
|
-
default: '{}',
|
|
119
|
-
},
|
|
52
|
+
client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : 'Partial<RequestConfig> & { client?: Client }'}
|
|
53
|
+
}`,
|
|
54
|
+
}),
|
|
55
|
+
default: '{}',
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
return ast.createOperationParams(node, {
|
|
59
|
+
paramsType,
|
|
60
|
+
pathParamsType: paramsType === 'object' ? 'object' : pathParamsType === 'object' ? 'object' : 'inline',
|
|
61
|
+
paramsCasing,
|
|
62
|
+
resolver,
|
|
63
|
+
extraParams: [optionsParam],
|
|
120
64
|
})
|
|
121
65
|
}
|
|
122
66
|
|
|
@@ -129,55 +73,38 @@ export function Query({
|
|
|
129
73
|
paramsCasing,
|
|
130
74
|
pathParamsType,
|
|
131
75
|
dataReturnType,
|
|
132
|
-
|
|
133
|
-
|
|
76
|
+
node,
|
|
77
|
+
tsResolver,
|
|
134
78
|
customOptions,
|
|
135
|
-
}: Props):
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
|
|
79
|
+
}: Props): KubbReactNode {
|
|
80
|
+
const responseName = tsResolver.resolveResponseName(node)
|
|
81
|
+
const errorNames = resolveErrorNames(node, tsResolver)
|
|
82
|
+
|
|
83
|
+
const TData = dataReturnType === 'data' ? responseName : `ResponseConfig<${responseName}>`
|
|
84
|
+
const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(' | ') : 'Error'}>`
|
|
85
|
+
const returnType = `UseQueryResult<${'TData'}, ${TError}> & { queryKey: TQueryKey }`
|
|
139
86
|
const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
|
|
140
87
|
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const queryOptionsParams = QueryOptions.getParams({
|
|
147
|
-
paramsType,
|
|
148
|
-
pathParamsType,
|
|
149
|
-
typeSchemas,
|
|
150
|
-
paramsCasing,
|
|
151
|
-
})
|
|
152
|
-
const params = getParams({
|
|
153
|
-
paramsCasing,
|
|
154
|
-
paramsType,
|
|
155
|
-
pathParamsType,
|
|
156
|
-
dataReturnType,
|
|
157
|
-
typeSchemas,
|
|
158
|
-
})
|
|
88
|
+
const queryKeyParamsNode = QueryKey.getParams(node, { pathParamsType, paramsCasing, resolver: tsResolver })
|
|
89
|
+
const queryKeyParamsCall = callPrinter.print(queryKeyParamsNode) ?? ''
|
|
90
|
+
|
|
91
|
+
const queryOptionsParamsNode = getQueryOptionsParams(node, { paramsType, paramsCasing, pathParamsType, resolver: tsResolver })
|
|
92
|
+
const queryOptionsParamsCall = callPrinter.print(queryOptionsParamsNode) ?? ''
|
|
159
93
|
|
|
160
|
-
const
|
|
94
|
+
const paramsNode = getParams(node, { paramsType, paramsCasing, pathParamsType, dataReturnType, resolver: tsResolver })
|
|
95
|
+
const paramsSignature = declarationPrinter.print(paramsNode) ?? ''
|
|
161
96
|
|
|
162
97
|
return (
|
|
163
98
|
<File.Source name={name} isExportable isIndexable>
|
|
164
|
-
<Function
|
|
165
|
-
name={name}
|
|
166
|
-
export
|
|
167
|
-
generics={generics.join(', ')}
|
|
168
|
-
params={params.toConstructor()}
|
|
169
|
-
JSDoc={{
|
|
170
|
-
comments: getComments(operation),
|
|
171
|
-
}}
|
|
172
|
-
>
|
|
99
|
+
<Function name={name} export generics={generics.join(', ')} params={paramsSignature} returnType={undefined} JSDoc={{ comments: getComments(node) }}>
|
|
173
100
|
{`
|
|
174
101
|
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
175
102
|
const { client: queryClient, ...resolvedOptions } = queryConfig
|
|
176
|
-
const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${
|
|
177
|
-
${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${
|
|
103
|
+
const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})
|
|
104
|
+
${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ''}
|
|
178
105
|
|
|
179
106
|
const query = useQuery({
|
|
180
|
-
...${
|
|
107
|
+
...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? '\n...customOptions,' : ''}
|
|
181
108
|
...resolvedOptions,
|
|
182
109
|
queryKey,
|
|
183
110
|
} as unknown as QueryObserverOptions, queryClient) as ${returnType}
|