@graphql-codegen/typescript-vue-apollo 4.0.0 → 4.1.0-alpha-20231016213233-b7f0390fa
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/cjs/visitor.js +6 -4
- package/esm/visitor.js +6 -4
- package/package.json +1 -1
- package/typings/config.d.cts +23 -0
- package/typings/config.d.ts +23 -0
- package/typings/visitor.d.cts +1 -0
- package/typings/visitor.d.ts +1 -0
package/cjs/visitor.js
CHANGED
|
@@ -15,6 +15,7 @@ class VueApolloVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
|
|
|
15
15
|
vueApolloComposableImportFrom: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.vueApolloComposableImportFrom, '@vue/apollo-composable'),
|
|
16
16
|
vueCompositionApiImportFrom: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.vueCompositionApiImportFrom, '@vue/composition-api'),
|
|
17
17
|
addDocBlocks: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.addDocBlocks, true),
|
|
18
|
+
clientId: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.clientId, null),
|
|
18
19
|
});
|
|
19
20
|
this.imports = new Set();
|
|
20
21
|
this.externalImportPrefix = this.config.importOperationTypesFrom
|
|
@@ -172,25 +173,26 @@ class VueApolloVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
|
|
|
172
173
|
const variables = operationHasVariables
|
|
173
174
|
? `variables: ${operationVariablesTypes} | VueCompositionApi.Ref<${operationVariablesTypes}> | ReactiveFunction<${operationVariablesTypes}>${operationHasNonNullableVariable ? '' : ' = {}'}, `
|
|
174
175
|
: '';
|
|
176
|
+
const options = `${this.config.clientId ? `{ clientId: '${this.config.clientId}', ...options}` : 'options'}`;
|
|
175
177
|
switch (operationType) {
|
|
176
178
|
case 'Query': {
|
|
177
179
|
return `export function use${operationName}(${variables}options: VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}> | VueCompositionApi.Ref<VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}>> | ReactiveFunction<VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}>> = {}) {
|
|
178
|
-
return VueApolloComposable.useQuery<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${operationHasVariables ? 'variables' : '{}'}, options);
|
|
180
|
+
return VueApolloComposable.useQuery<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${operationHasVariables ? 'variables' : '{}'}, ${options});
|
|
179
181
|
}`;
|
|
180
182
|
}
|
|
181
183
|
case 'LazyQuery': {
|
|
182
184
|
return `export function use${operationName}(${variables}options: VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}> | VueCompositionApi.Ref<VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}>> | ReactiveFunction<VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}>> = {}) {
|
|
183
|
-
return VueApolloComposable.useLazyQuery<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${operationHasVariables ? 'variables' : '{}'}, options);
|
|
185
|
+
return VueApolloComposable.useLazyQuery<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${operationHasVariables ? 'variables' : '{}'}, ${options});
|
|
184
186
|
}`;
|
|
185
187
|
}
|
|
186
188
|
case 'Mutation': {
|
|
187
189
|
return `export function use${operationName}(options: VueApolloComposable.UseMutationOptions<${operationResultType}, ${operationVariablesTypes}> | ReactiveFunction<VueApolloComposable.UseMutationOptions<${operationResultType}, ${operationVariablesTypes}>> = {}) {
|
|
188
|
-
return VueApolloComposable.useMutation<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, options);
|
|
190
|
+
return VueApolloComposable.useMutation<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${options});
|
|
189
191
|
}`;
|
|
190
192
|
}
|
|
191
193
|
case 'Subscription': {
|
|
192
194
|
return `export function use${operationName}(${variables}options: VueApolloComposable.UseSubscriptionOptions<${operationResultType}, ${operationVariablesTypes}> | VueCompositionApi.Ref<VueApolloComposable.UseSubscriptionOptions<${operationResultType}, ${operationVariablesTypes}>> | ReactiveFunction<VueApolloComposable.UseSubscriptionOptions<${operationResultType}, ${operationVariablesTypes}>> = {}) {
|
|
193
|
-
return VueApolloComposable.useSubscription<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${operationHasVariables ? 'variables' : '{}'}, options);
|
|
195
|
+
return VueApolloComposable.useSubscription<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${operationHasVariables ? 'variables' : '{}'}, ${options});
|
|
194
196
|
}`;
|
|
195
197
|
}
|
|
196
198
|
}
|
package/esm/visitor.js
CHANGED
|
@@ -11,6 +11,7 @@ export class VueApolloVisitor extends ClientSideBaseVisitor {
|
|
|
11
11
|
vueApolloComposableImportFrom: getConfigValue(rawConfig.vueApolloComposableImportFrom, '@vue/apollo-composable'),
|
|
12
12
|
vueCompositionApiImportFrom: getConfigValue(rawConfig.vueCompositionApiImportFrom, '@vue/composition-api'),
|
|
13
13
|
addDocBlocks: getConfigValue(rawConfig.addDocBlocks, true),
|
|
14
|
+
clientId: getConfigValue(rawConfig.clientId, null),
|
|
14
15
|
});
|
|
15
16
|
this.imports = new Set();
|
|
16
17
|
this.externalImportPrefix = this.config.importOperationTypesFrom
|
|
@@ -168,25 +169,26 @@ export class VueApolloVisitor extends ClientSideBaseVisitor {
|
|
|
168
169
|
const variables = operationHasVariables
|
|
169
170
|
? `variables: ${operationVariablesTypes} | VueCompositionApi.Ref<${operationVariablesTypes}> | ReactiveFunction<${operationVariablesTypes}>${operationHasNonNullableVariable ? '' : ' = {}'}, `
|
|
170
171
|
: '';
|
|
172
|
+
const options = `${this.config.clientId ? `{ clientId: '${this.config.clientId}', ...options}` : 'options'}`;
|
|
171
173
|
switch (operationType) {
|
|
172
174
|
case 'Query': {
|
|
173
175
|
return `export function use${operationName}(${variables}options: VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}> | VueCompositionApi.Ref<VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}>> | ReactiveFunction<VueApolloComposable.UseQueryOptions<${operationResultType}, ${operationVariablesTypes}>> = {}) {
|
|
174
|
-
return VueApolloComposable.useQuery<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${operationHasVariables ? 'variables' : '{}'}, options);
|
|
176
|
+
return VueApolloComposable.useQuery<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${operationHasVariables ? 'variables' : '{}'}, ${options});
|
|
175
177
|
}`;
|
|
176
178
|
}
|
|
177
179
|
case 'LazyQuery': {
|
|
178
180
|
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);
|
|
181
|
+
return VueApolloComposable.useLazyQuery<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${operationHasVariables ? 'variables' : '{}'}, ${options});
|
|
180
182
|
}`;
|
|
181
183
|
}
|
|
182
184
|
case 'Mutation': {
|
|
183
185
|
return `export function use${operationName}(options: VueApolloComposable.UseMutationOptions<${operationResultType}, ${operationVariablesTypes}> | ReactiveFunction<VueApolloComposable.UseMutationOptions<${operationResultType}, ${operationVariablesTypes}>> = {}) {
|
|
184
|
-
return VueApolloComposable.useMutation<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, options);
|
|
186
|
+
return VueApolloComposable.useMutation<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${options});
|
|
185
187
|
}`;
|
|
186
188
|
}
|
|
187
189
|
case 'Subscription': {
|
|
188
190
|
return `export function use${operationName}(${variables}options: VueApolloComposable.UseSubscriptionOptions<${operationResultType}, ${operationVariablesTypes}> | VueCompositionApi.Ref<VueApolloComposable.UseSubscriptionOptions<${operationResultType}, ${operationVariablesTypes}>> | ReactiveFunction<VueApolloComposable.UseSubscriptionOptions<${operationResultType}, ${operationVariablesTypes}>> = {}) {
|
|
189
|
-
return VueApolloComposable.useSubscription<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${operationHasVariables ? 'variables' : '{}'}, options);
|
|
191
|
+
return VueApolloComposable.useSubscription<${operationResultType}, ${operationVariablesTypes}>(${documentNodeVariable}, ${operationHasVariables ? 'variables' : '{}'}, ${options});
|
|
190
192
|
}`;
|
|
191
193
|
}
|
|
192
194
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-vue-apollo",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0-alpha-20231016213233-b7f0390fa",
|
|
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",
|
package/typings/config.d.cts
CHANGED
|
@@ -99,4 +99,27 @@ export interface VueApolloRawPluginConfig extends RawClientSideBasePluginConfig
|
|
|
99
99
|
* ```
|
|
100
100
|
*/
|
|
101
101
|
addDocBlocks?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* @description Allows you to set the clientId in the composition functions when using multiple apollo clients.
|
|
104
|
+
* @default null
|
|
105
|
+
*
|
|
106
|
+
* @exampleMarkdown
|
|
107
|
+
* ```ts filename="codegen.ts"
|
|
108
|
+
* import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
109
|
+
*
|
|
110
|
+
* const config: CodegenConfig = {
|
|
111
|
+
* // ...
|
|
112
|
+
* generates: {
|
|
113
|
+
* 'path/to/file.ts': {
|
|
114
|
+
* plugins: ['typescript', 'typescript-operations', 'typescript-vue-apollo'],
|
|
115
|
+
* config: {
|
|
116
|
+
* clientId: 'customClient'
|
|
117
|
+
* },
|
|
118
|
+
* },
|
|
119
|
+
* },
|
|
120
|
+
* };
|
|
121
|
+
* export default config;
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
clientId?: string;
|
|
102
125
|
}
|
package/typings/config.d.ts
CHANGED
|
@@ -99,4 +99,27 @@ export interface VueApolloRawPluginConfig extends RawClientSideBasePluginConfig
|
|
|
99
99
|
* ```
|
|
100
100
|
*/
|
|
101
101
|
addDocBlocks?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* @description Allows you to set the clientId in the composition functions when using multiple apollo clients.
|
|
104
|
+
* @default null
|
|
105
|
+
*
|
|
106
|
+
* @exampleMarkdown
|
|
107
|
+
* ```ts filename="codegen.ts"
|
|
108
|
+
* import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
109
|
+
*
|
|
110
|
+
* const config: CodegenConfig = {
|
|
111
|
+
* // ...
|
|
112
|
+
* generates: {
|
|
113
|
+
* 'path/to/file.ts': {
|
|
114
|
+
* plugins: ['typescript', 'typescript-operations', 'typescript-vue-apollo'],
|
|
115
|
+
* config: {
|
|
116
|
+
* clientId: 'customClient'
|
|
117
|
+
* },
|
|
118
|
+
* },
|
|
119
|
+
* },
|
|
120
|
+
* };
|
|
121
|
+
* export default config;
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
clientId?: string;
|
|
102
125
|
}
|
package/typings/visitor.d.cts
CHANGED
|
@@ -7,6 +7,7 @@ export interface VueApolloPluginConfig extends ClientSideBasePluginConfig {
|
|
|
7
7
|
vueApolloComposableImportFrom: 'vue' | '@vue/apollo-composable' | string;
|
|
8
8
|
vueCompositionApiImportFrom: 'vue' | '@vue/apollo-composable' | string;
|
|
9
9
|
addDocBlocks: boolean;
|
|
10
|
+
clientId?: string;
|
|
10
11
|
}
|
|
11
12
|
export declare class VueApolloVisitor extends ClientSideBaseVisitor<VueApolloRawPluginConfig, VueApolloPluginConfig> {
|
|
12
13
|
private externalImportPrefix;
|
package/typings/visitor.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface VueApolloPluginConfig extends ClientSideBasePluginConfig {
|
|
|
7
7
|
vueApolloComposableImportFrom: 'vue' | '@vue/apollo-composable' | string;
|
|
8
8
|
vueCompositionApiImportFrom: 'vue' | '@vue/apollo-composable' | string;
|
|
9
9
|
addDocBlocks: boolean;
|
|
10
|
+
clientId?: string;
|
|
10
11
|
}
|
|
11
12
|
export declare class VueApolloVisitor extends ClientSideBaseVisitor<VueApolloRawPluginConfig, VueApolloPluginConfig> {
|
|
12
13
|
private externalImportPrefix;
|