@graphql-codegen/typescript-vue-apollo 3.2.3-alpha-6cdbcf02e.0 → 3.2.4-alpha-06d103feb.0
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/index.js +33 -10
- package/index.mjs +34 -11
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -131,18 +131,36 @@ class VueApolloVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
|
|
|
131
131
|
operationResultType,
|
|
132
132
|
operationVariablesTypes,
|
|
133
133
|
});
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
134
|
+
const compositionFunctions = [
|
|
135
|
+
this.buildCompositionFunction({
|
|
136
|
+
operationName,
|
|
137
|
+
operationType,
|
|
138
|
+
operationResultType,
|
|
139
|
+
operationVariablesTypes,
|
|
140
|
+
operationHasNonNullableVariable,
|
|
141
|
+
operationHasVariables,
|
|
142
|
+
documentNodeVariable,
|
|
143
|
+
}),
|
|
144
|
+
];
|
|
145
|
+
if (operationType === 'Query') {
|
|
146
|
+
const lazyOperationName = this.convertName(node.name.value, {
|
|
147
|
+
suffix: changeCaseAll.titleCase('LazyQuery'),
|
|
148
|
+
useTypesPrefix: false,
|
|
149
|
+
});
|
|
150
|
+
const lazyOperationType = 'LazyQuery';
|
|
151
|
+
compositionFunctions.push(this.buildCompositionFunction({
|
|
152
|
+
operationName: lazyOperationName,
|
|
153
|
+
operationType: lazyOperationType,
|
|
154
|
+
operationResultType,
|
|
155
|
+
operationVariablesTypes,
|
|
156
|
+
operationHasNonNullableVariable,
|
|
157
|
+
operationHasVariables,
|
|
158
|
+
documentNodeVariable,
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
143
161
|
return [
|
|
144
162
|
...insertIf(this.config.addDocBlocks, [this.buildCompositionFunctionsJSDoc(node, operationName, operationType)]),
|
|
145
|
-
|
|
163
|
+
compositionFunctions.join('\n'),
|
|
146
164
|
compositionFunctionResultType,
|
|
147
165
|
].join('\n');
|
|
148
166
|
}
|
|
@@ -154,6 +172,11 @@ class VueApolloVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
|
|
|
154
172
|
case 'Query': {
|
|
155
173
|
return `export function use${operationName}(${variables}options: VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}> | VueCompositionApi.Ref<VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}>> | ReactiveFunction<VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}>> = {}) {
|
|
156
174
|
return VueApolloComposable.useQuery<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${operationHasVariables ? 'variables' : '{}'}, options);
|
|
175
|
+
}`;
|
|
176
|
+
}
|
|
177
|
+
case 'LazyQuery': {
|
|
178
|
+
return `export function use${operationName}(${variables}options: VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}> | VueCompositionApi.Ref<VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}>> | ReactiveFunction<VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}>> = {}) {
|
|
179
|
+
return VueApolloComposable.useLazyQuery<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${operationHasVariables ? 'variables' : '{}'}, options);
|
|
157
180
|
}`;
|
|
158
181
|
}
|
|
159
182
|
case 'Mutation': {
|
package/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { oldVisit } from '@graphql-codegen/plugin-helpers';
|
|
|
2
2
|
import { concatAST, Kind } from 'graphql';
|
|
3
3
|
import { ClientSideBaseVisitor, getConfigValue, DocumentMode } from '@graphql-codegen/visitor-plugin-common';
|
|
4
4
|
import autoBind from 'auto-bind';
|
|
5
|
-
import { pascalCase } from 'change-case-all';
|
|
5
|
+
import { pascalCase, titleCase } from 'change-case-all';
|
|
6
6
|
import { extname } from 'path';
|
|
7
7
|
|
|
8
8
|
function insertIf(condition, ...elements) {
|
|
@@ -125,18 +125,36 @@ class VueApolloVisitor extends ClientSideBaseVisitor {
|
|
|
125
125
|
operationResultType,
|
|
126
126
|
operationVariablesTypes,
|
|
127
127
|
});
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
128
|
+
const compositionFunctions = [
|
|
129
|
+
this.buildCompositionFunction({
|
|
130
|
+
operationName,
|
|
131
|
+
operationType,
|
|
132
|
+
operationResultType,
|
|
133
|
+
operationVariablesTypes,
|
|
134
|
+
operationHasNonNullableVariable,
|
|
135
|
+
operationHasVariables,
|
|
136
|
+
documentNodeVariable,
|
|
137
|
+
}),
|
|
138
|
+
];
|
|
139
|
+
if (operationType === 'Query') {
|
|
140
|
+
const lazyOperationName = this.convertName(node.name.value, {
|
|
141
|
+
suffix: titleCase('LazyQuery'),
|
|
142
|
+
useTypesPrefix: false,
|
|
143
|
+
});
|
|
144
|
+
const lazyOperationType = 'LazyQuery';
|
|
145
|
+
compositionFunctions.push(this.buildCompositionFunction({
|
|
146
|
+
operationName: lazyOperationName,
|
|
147
|
+
operationType: lazyOperationType,
|
|
148
|
+
operationResultType,
|
|
149
|
+
operationVariablesTypes,
|
|
150
|
+
operationHasNonNullableVariable,
|
|
151
|
+
operationHasVariables,
|
|
152
|
+
documentNodeVariable,
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
137
155
|
return [
|
|
138
156
|
...insertIf(this.config.addDocBlocks, [this.buildCompositionFunctionsJSDoc(node, operationName, operationType)]),
|
|
139
|
-
|
|
157
|
+
compositionFunctions.join('\n'),
|
|
140
158
|
compositionFunctionResultType,
|
|
141
159
|
].join('\n');
|
|
142
160
|
}
|
|
@@ -148,6 +166,11 @@ class VueApolloVisitor extends ClientSideBaseVisitor {
|
|
|
148
166
|
case 'Query': {
|
|
149
167
|
return `export function use${operationName}(${variables}options: VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}> | VueCompositionApi.Ref<VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}>> | ReactiveFunction<VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}>> = {}) {
|
|
150
168
|
return VueApolloComposable.useQuery<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${operationHasVariables ? 'variables' : '{}'}, options);
|
|
169
|
+
}`;
|
|
170
|
+
}
|
|
171
|
+
case 'LazyQuery': {
|
|
172
|
+
return `export function use${operationName}(${variables}options: VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}> | VueCompositionApi.Ref<VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}>> | ReactiveFunction<VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}>> = {}) {
|
|
173
|
+
return VueApolloComposable.useLazyQuery<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${operationHasVariables ? 'variables' : '{}'}, options);
|
|
151
174
|
}`;
|
|
152
175
|
}
|
|
153
176
|
case 'Mutation': {
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-vue-apollo",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.4-alpha-06d103feb.0",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating ready-to-use Vue-Apollo composition functions based on GraphQL operations",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
7
7
|
"graphql-tag": "^2.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-codegen/plugin-helpers": "2.3.
|
|
11
|
-
"@graphql-codegen/visitor-plugin-common": "2.5.3-alpha-
|
|
10
|
+
"@graphql-codegen/plugin-helpers": "^2.3.2",
|
|
11
|
+
"@graphql-codegen/visitor-plugin-common": "2.5.3-alpha-06d103feb.0",
|
|
12
12
|
"auto-bind": "~4.0.0",
|
|
13
13
|
"change-case-all": "1.0.14",
|
|
14
14
|
"tslib": "~2.3.0"
|