@kubb/plugin-react-query 5.0.0-alpha.8 → 5.0.0-beta.10
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 +34 -85
- package/dist/components-Dow6tde8.js +1459 -0
- package/dist/components-Dow6tde8.js.map +1 -0
- package/dist/components-HwdCDefj.cjs +1603 -0
- package/dist/components-HwdCDefj.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +49 -179
- package/dist/components.js +1 -1
- package/dist/generators-CcOmnTPa.cjs +1454 -0
- package/dist/generators-CcOmnTPa.cjs.map +1 -0
- package/dist/generators-yfZr_qfT.js +1412 -0
- package/dist/generators-yfZr_qfT.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +9 -476
- package/dist/generators.js +1 -1
- package/dist/index.cjs +197 -126
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +193 -126
- package/dist/index.js.map +1 -1
- package/dist/types-DG_OxOym.d.ts +363 -0
- package/extension.yaml +911 -0
- package/package.json +59 -64
- package/src/components/InfiniteQuery.tsx +79 -138
- package/src/components/InfiniteQueryOptions.tsx +55 -166
- package/src/components/Mutation.tsx +74 -111
- package/src/components/MutationOptions.tsx +61 -80
- package/src/components/Query.tsx +66 -142
- package/src/components/QueryOptions.tsx +56 -138
- package/src/components/SuspenseInfiniteQuery.tsx +79 -138
- package/src/components/SuspenseInfiniteQueryOptions.tsx +55 -166
- package/src/components/SuspenseQuery.tsx +66 -152
- package/src/generators/customHookOptionsFileGenerator.tsx +37 -51
- package/src/generators/hookOptionsGenerator.tsx +111 -174
- package/src/generators/infiniteQueryGenerator.tsx +158 -178
- package/src/generators/mutationGenerator.tsx +112 -139
- package/src/generators/queryGenerator.tsx +128 -142
- package/src/generators/suspenseInfiniteQueryGenerator.tsx +157 -156
- package/src/generators/suspenseQueryGenerator.tsx +126 -152
- package/src/index.ts +1 -1
- package/src/plugin.ts +134 -187
- package/src/resolvers/resolverReactQuery.ts +107 -0
- package/src/types.ts +172 -49
- package/src/utils.ts +10 -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
- package/dist/types-D5S7Ny9r.d.ts +0 -270
|
@@ -1,35 +1,39 @@
|
|
|
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 { buildRequestConfigType, 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
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
:
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
export function buildMutationConfigParamsNode(node: ast.OperationNode, resolver: ResolverTs): ast.FunctionParametersNode {
|
|
26
|
+
return ast.createFunctionParameters({
|
|
27
|
+
params: [
|
|
28
|
+
ast.createFunctionParameter({
|
|
29
|
+
name: 'config',
|
|
30
|
+
type: ast.createParamsType({
|
|
31
|
+
variant: 'reference',
|
|
32
|
+
name: buildRequestConfigType(node, resolver),
|
|
33
|
+
}),
|
|
34
|
+
default: '{}',
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
33
37
|
})
|
|
34
38
|
}
|
|
35
39
|
|
|
@@ -37,80 +41,59 @@ export function MutationOptions({
|
|
|
37
41
|
name,
|
|
38
42
|
clientName,
|
|
39
43
|
dataReturnType,
|
|
40
|
-
|
|
44
|
+
node,
|
|
45
|
+
tsResolver,
|
|
41
46
|
paramsCasing,
|
|
42
47
|
paramsType,
|
|
43
48
|
pathParamsType,
|
|
44
49
|
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
|
-
})
|
|
50
|
+
}: Props): KubbReactNode {
|
|
51
|
+
const responseName = tsResolver.resolveResponseName(node)
|
|
52
|
+
const TData = dataReturnType === 'data' ? responseName : `ResponseConfig<${responseName}>`
|
|
53
|
+
const errorNames = resolveErrorNames(node, tsResolver)
|
|
54
|
+
const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(' | ') : 'Error'}>`
|
|
57
55
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
typeSchemas,
|
|
61
|
-
})
|
|
56
|
+
const configParamsNode = buildMutationConfigParamsNode(node, tsResolver)
|
|
57
|
+
const paramsSignature = declarationPrinter.print(configParamsNode) ?? ''
|
|
62
58
|
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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,
|
|
59
|
+
const mutationArgParamsNode = ast.createOperationParams(node, {
|
|
60
|
+
paramsType: 'inline',
|
|
61
|
+
pathParamsType: 'inline',
|
|
62
|
+
paramsCasing,
|
|
63
|
+
resolver: tsResolver,
|
|
83
64
|
})
|
|
65
|
+
const hasMutationParams = mutationArgParamsNode.params.length > 0
|
|
84
66
|
|
|
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
|
-
}
|
|
67
|
+
const TRequest = hasMutationParams ? (declarationPrinter.print(mutationArgParamsNode) ?? '') : ''
|
|
68
|
+
const argKeysStr = hasMutationParams ? (keysPrinter.print(mutationArgParamsNode) ?? '') : ''
|
|
97
69
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
70
|
+
const clientCallParamsNode = ast.createOperationParams(node, {
|
|
71
|
+
paramsType,
|
|
72
|
+
pathParamsType: paramsType === 'object' ? 'object' : pathParamsType === 'object' ? 'object' : 'inline',
|
|
73
|
+
paramsCasing,
|
|
74
|
+
resolver: tsResolver,
|
|
75
|
+
extraParams: [
|
|
76
|
+
ast.createFunctionParameter({
|
|
77
|
+
name: 'config',
|
|
78
|
+
type: ast.createParamsType({
|
|
79
|
+
variant: 'reference',
|
|
80
|
+
name: buildRequestConfigType(node, tsResolver),
|
|
81
|
+
}),
|
|
82
|
+
default: '{}',
|
|
83
|
+
}),
|
|
84
|
+
],
|
|
101
85
|
})
|
|
102
|
-
|
|
103
|
-
const TRequest = mutationParams.toConstructor()
|
|
86
|
+
const clientCallStr = callPrinter.print(clientCallParamsNode) ?? ''
|
|
104
87
|
|
|
105
88
|
return (
|
|
106
89
|
<File.Source name={name} isExportable isIndexable>
|
|
107
|
-
<Function name={name} export params={
|
|
90
|
+
<Function name={name} export params={paramsSignature} generics={['TContext = unknown']}>
|
|
108
91
|
{`
|
|
109
|
-
const mutationKey = ${mutationKeyName}(
|
|
110
|
-
return mutationOptions<${TData},
|
|
92
|
+
const mutationKey = ${mutationKeyName}()
|
|
93
|
+
return mutationOptions<${TData}, ${TError}, ${TRequest ? `{${TRequest}}` : 'void'}, TContext>({
|
|
111
94
|
mutationKey,
|
|
112
|
-
mutationFn: async(${
|
|
113
|
-
return ${clientName}(${
|
|
95
|
+
mutationFn: async(${hasMutationParams ? `{ ${argKeysStr} }` : '_'}) => {
|
|
96
|
+
return ${clientName}(${clientCallStr})
|
|
114
97
|
},
|
|
115
98
|
})
|
|
116
99
|
`}
|
|
@@ -118,5 +101,3 @@ export function MutationOptions({
|
|
|
118
101
|
</File.Source>
|
|
119
102
|
)
|
|
120
103
|
}
|
|
121
|
-
|
|
122
|
-
MutationOptions.getParams = getParams
|
package/src/components/Query.tsx
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
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 {
|
|
8
|
-
import {
|
|
7
|
+
import { buildQueryKeyParams, getComments, resolveErrorNames } from '../utils.ts'
|
|
8
|
+
import { getQueryOptionsParams } from './QueryOptions.tsx'
|
|
9
9
|
|
|
10
10
|
type Props = {
|
|
11
|
-
/**
|
|
12
|
-
* Name of the function
|
|
13
|
-
*/
|
|
14
11
|
name: string
|
|
15
12
|
queryOptionsName: string
|
|
16
13
|
queryKeyName: string
|
|
17
14
|
queryKeyTypeName: string
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
node: ast.OperationNode
|
|
16
|
+
tsResolver: ResolverTs
|
|
20
17
|
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
21
18
|
paramsType: PluginReactQuery['resolvedOptions']['paramsType']
|
|
22
19
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
|
|
@@ -24,99 +21,45 @@ type Props = {
|
|
|
24
21
|
customOptions: PluginReactQuery['resolvedOptions']['customOptions']
|
|
25
22
|
}
|
|
26
23
|
|
|
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
|
-
{
|
|
24
|
+
const declarationPrinter = functionPrinter({ mode: 'declaration' })
|
|
25
|
+
const callPrinter = functionPrinter({ mode: 'call' })
|
|
26
|
+
|
|
27
|
+
function buildQueryParamsNode(
|
|
28
|
+
node: ast.OperationNode,
|
|
29
|
+
options: {
|
|
30
|
+
paramsType: PluginReactQuery['resolvedOptions']['paramsType']
|
|
31
|
+
paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
|
|
32
|
+
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
|
|
33
|
+
dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
|
|
34
|
+
resolver: ResolverTs
|
|
35
|
+
},
|
|
36
|
+
): ast.FunctionParametersNode {
|
|
37
|
+
const { paramsType, paramsCasing, pathParamsType, dataReturnType, resolver } = options
|
|
38
|
+
const responseName = resolver.resolveResponseName(node)
|
|
39
|
+
const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : undefined
|
|
40
|
+
const errorNames = resolveErrorNames(node, resolver)
|
|
41
|
+
|
|
42
|
+
const TData = dataReturnType === 'data' ? responseName : `ResponseConfig<${responseName}>`
|
|
43
|
+
const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(' | ') : 'Error'}>`
|
|
44
|
+
|
|
45
|
+
const optionsParam = ast.createFunctionParameter({
|
|
46
|
+
name: 'options',
|
|
47
|
+
type: ast.createParamsType({
|
|
48
|
+
variant: 'reference',
|
|
49
|
+
name: `{
|
|
76
50
|
query?: Partial<QueryObserverOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },
|
|
77
|
-
client?: ${
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})
|
|
83
|
-
}
|
|
51
|
+
client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : 'Partial<RequestConfig> & { client?: Client }'}
|
|
52
|
+
}`,
|
|
53
|
+
}),
|
|
54
|
+
default: '{}',
|
|
55
|
+
})
|
|
84
56
|
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
},
|
|
57
|
+
return ast.createOperationParams(node, {
|
|
58
|
+
paramsType,
|
|
59
|
+
pathParamsType: paramsType === 'object' ? 'object' : pathParamsType === 'object' ? 'object' : 'inline',
|
|
60
|
+
paramsCasing,
|
|
61
|
+
resolver,
|
|
62
|
+
extraParams: [optionsParam],
|
|
120
63
|
})
|
|
121
64
|
}
|
|
122
65
|
|
|
@@ -129,55 +72,38 @@ export function Query({
|
|
|
129
72
|
paramsCasing,
|
|
130
73
|
pathParamsType,
|
|
131
74
|
dataReturnType,
|
|
132
|
-
|
|
133
|
-
|
|
75
|
+
node,
|
|
76
|
+
tsResolver,
|
|
134
77
|
customOptions,
|
|
135
|
-
}: Props):
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
|
|
78
|
+
}: Props): KubbReactNode {
|
|
79
|
+
const responseName = tsResolver.resolveResponseName(node)
|
|
80
|
+
const errorNames = resolveErrorNames(node, tsResolver)
|
|
81
|
+
|
|
82
|
+
const TData = dataReturnType === 'data' ? responseName : `ResponseConfig<${responseName}>`
|
|
83
|
+
const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(' | ') : 'Error'}>`
|
|
84
|
+
const returnType = `UseQueryResult<${'TData'}, ${TError}> & { queryKey: TQueryKey }`
|
|
139
85
|
const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
|
|
140
86
|
|
|
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
|
-
})
|
|
87
|
+
const queryKeyParamsNode = buildQueryKeyParams(node, { pathParamsType, paramsCasing, resolver: tsResolver })
|
|
88
|
+
const queryKeyParamsCall = callPrinter.print(queryKeyParamsNode) ?? ''
|
|
89
|
+
|
|
90
|
+
const queryOptionsParamsNode = getQueryOptionsParams(node, { paramsType, paramsCasing, pathParamsType, resolver: tsResolver })
|
|
91
|
+
const queryOptionsParamsCall = callPrinter.print(queryOptionsParamsNode) ?? ''
|
|
159
92
|
|
|
160
|
-
const
|
|
93
|
+
const paramsNode = buildQueryParamsNode(node, { paramsType, paramsCasing, pathParamsType, dataReturnType, resolver: tsResolver })
|
|
94
|
+
const paramsSignature = declarationPrinter.print(paramsNode) ?? ''
|
|
161
95
|
|
|
162
96
|
return (
|
|
163
97
|
<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
|
-
>
|
|
98
|
+
<Function name={name} export generics={generics.join(', ')} params={paramsSignature} returnType={undefined} JSDoc={{ comments: getComments(node) }}>
|
|
173
99
|
{`
|
|
174
100
|
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
175
101
|
const { client: queryClient, ...resolvedOptions } = queryConfig
|
|
176
|
-
const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${
|
|
177
|
-
${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${
|
|
102
|
+
const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})
|
|
103
|
+
${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ''}
|
|
178
104
|
|
|
179
105
|
const query = useQuery({
|
|
180
|
-
...${
|
|
106
|
+
...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? '\n...customOptions,' : ''}
|
|
181
107
|
...resolvedOptions,
|
|
182
108
|
queryKey,
|
|
183
109
|
} as unknown as QueryObserverOptions, queryClient) as ${returnType}
|
|
@@ -190,5 +116,3 @@ export function Query({
|
|
|
190
116
|
</File.Source>
|
|
191
117
|
)
|
|
192
118
|
}
|
|
193
|
-
|
|
194
|
-
Query.getParams = getParams
|