@vladimirdev635/gql-codegen 0.0.108 → 0.0.110
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/actors/ts/gql-client/actor.d.ts +7 -1
- package/actors/ts/gql-client/actor.js +1 -1
- package/actors/ts/gql-client/generators/help-nodes/build-subscription-callback-function.d.ts +4 -0
- package/actors/ts/gql-client/generators/help-nodes/build-subscription-callback-function.js +35 -0
- package/actors/ts/gql-client/generators/help-nodes/build-sync-callback-function.d.ts +4 -0
- package/actors/ts/gql-client/generators/help-nodes/build-sync-callback-function.js +35 -0
- package/actors/ts/gql-client/generators/help-nodes/callback-arrow-func.d.ts +3 -0
- package/actors/ts/gql-client/generators/help-nodes/callback-arrow-func.js +15 -0
- package/actors/ts/gql-client/generators/help-nodes/index.d.ts +9 -0
- package/actors/ts/gql-client/generators/help-nodes/index.js +71 -0
- package/actors/ts/gql-client/generators/help-nodes/sdk-operations-type-node.d.ts +4 -0
- package/actors/ts/gql-client/generators/help-nodes/sdk-operations-type-node.js +17 -0
- package/actors/ts/gql-client/generators/help-nodes/sdk-type.d.ts +7 -0
- package/actors/ts/gql-client/generators/help-nodes/sdk-type.js +21 -0
- package/actors/ts/gql-client/generators/help-nodes/subscription-method-func-alias.d.ts +3 -0
- package/actors/ts/gql-client/generators/help-nodes/subscription-method-func-alias.js +14 -0
- package/actors/ts/gql-client/generators/help-nodes/sync-method-func-alias.d.ts +3 -0
- package/actors/ts/gql-client/generators/help-nodes/sync-method-func-alias.js +13 -0
- package/actors/ts/gql-client/generators/main.d.ts +1 -1
- package/actors/ts/gql-client/generators/main.js +41 -71
- package/actors/ts/gql-client/generators/operation-function-block.d.ts +3 -0
- package/actors/ts/gql-client/generators/operation-function-block.js +21 -0
- package/actors/ts/gql-client/generators/operation-return-type.d.ts +4 -0
- package/actors/ts/gql-client/generators/operation-return-type.js +16 -0
- package/actors/ts/gql-client-framework/actor.d.ts +42 -0
- package/actors/ts/gql-client-framework/actor.js +11 -0
- package/actors/ts/gql-client-framework/generators/help-nodes/index.d.ts +8 -0
- package/actors/ts/gql-client-framework/generators/help-nodes/index.js +55 -0
- package/actors/ts/gql-client-framework/generators/help-nodes/lazy-hook-builder.d.ts +4 -0
- package/actors/ts/gql-client-framework/generators/help-nodes/lazy-hook-builder.js +44 -0
- package/actors/ts/gql-client-framework/generators/help-nodes/sdk-operations-type-node.d.ts +4 -0
- package/actors/ts/gql-client-framework/generators/help-nodes/sdk-operations-type-node.js +45 -0
- package/actors/ts/gql-client-framework/generators/help-nodes/sdk-type.d.ts +7 -0
- package/actors/ts/gql-client-framework/generators/help-nodes/sdk-type.js +21 -0
- package/actors/ts/gql-client-framework/generators/help-nodes/subscription-hook-builders.d.ts +4 -0
- package/actors/ts/gql-client-framework/generators/help-nodes/subscription-hook-builders.js +52 -0
- package/actors/ts/gql-client-framework/generators/help-nodes/sync-hook-builders.d.ts +4 -0
- package/actors/ts/gql-client-framework/generators/help-nodes/sync-hook-builders.js +52 -0
- package/actors/ts/gql-client-framework/generators/main.js +88 -0
- package/actors/ts/gql-client-framework/index.d.ts +1 -0
- package/actors/ts/gql-client-framework/index.js +1 -0
- package/actors/ts/gql-client-react/actor.d.ts +5 -12
- package/actors/ts/gql-client-react/actor.js +10 -9
- package/actors/ts/gql-client-react/index.d.ts +1 -1
- package/actors/ts/gql-client-vue/actor.d.ts +5 -12
- package/actors/ts/gql-client-vue/actor.js +27 -9
- package/actors/ts/gql-client-vue/index.d.ts +1 -1
- package/actors/ts/graphql/actor.d.ts +6 -5
- package/actors/ts/graphql/actor.js +4 -4
- package/actors/ts/graphql/generators/client/fragments.d.ts +3 -3
- package/actors/ts/graphql/generators/client/fragments.js +24 -21
- package/actors/ts/graphql/generators/client/main.d.ts +3 -3
- package/actors/ts/graphql/generators/client/main.js +1 -18
- package/actors/ts/graphql/generators/client/operations.d.ts +4 -3
- package/actors/ts/graphql/generators/client/operations.js +22 -24
- package/actors/ts/graphql/generators/main.d.ts +2 -2
- package/actors/ts/graphql/generators/main.js +1 -1
- package/actors/ts/graphql/generators/server/inputs.d.ts +1 -1
- package/actors/ts/graphql/generators/server/inputs.js +6 -6
- package/actors/ts/graphql/generators/server/main.d.ts +2 -2
- package/actors/ts/graphql/generators/server/objects.js +2 -2
- package/actors/ts/graphql/generators/server/scalars/additional.d.ts +1 -0
- package/actors/ts/graphql/generators/server/scalars/additional.js +2 -1
- package/actors/ts/graphql/generators/server/shared.d.ts +3 -2
- package/actors/ts/graphql/generators/server/shared.js +10 -1
- package/actors/ts/graphql/generators/server/unions.js +2 -2
- package/actors/ts/graphql/index.d.ts +1 -1
- package/actors/ts/graphql/index.js +1 -1
- package/actors/ts/index.d.ts +2 -1
- package/actors/ts/index.js +1 -0
- package/actors/ts/shared.d.ts +5 -0
- package/actors/ts/utils.d.ts +2 -4
- package/actors/ts/utils.js +4 -3
- package/package.json +1 -1
- package/schema/client/operation.d.ts +3 -0
- package/schema/utils.d.ts +6 -6
- package/schema/utils.js +8 -6
- package/actors/ts/gql-client-react/generators/main.d.ts +0 -4
- package/actors/ts/gql-client-react/generators/main.js +0 -121
- package/actors/ts/gql-client-vue/generators/main.js +0 -135
- /package/actors/ts/{gql-client-vue → gql-client-framework}/generators/main.d.ts +0 -0
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
function generateFunctionBlock(operationName, type) {
|
|
3
|
-
switch (type) {
|
|
4
|
-
case 'SYNC':
|
|
5
|
-
return ts.factory.createCallExpression(ts.factory.createIdentifier('useOperation'), undefined, [
|
|
6
|
-
ts.factory.createIdentifier('executor'),
|
|
7
|
-
ts.factory.createIdentifier(operationName),
|
|
8
|
-
ts.factory.createIdentifier('variables'),
|
|
9
|
-
ts.factory.createIdentifier('requestContext'),
|
|
10
|
-
]);
|
|
11
|
-
case 'LAZY':
|
|
12
|
-
return ts.factory.createCallExpression(ts.factory.createIdentifier('useLazyOperation'), undefined, [
|
|
13
|
-
ts.factory.createIdentifier('executor'),
|
|
14
|
-
ts.factory.createIdentifier(operationName),
|
|
15
|
-
]);
|
|
16
|
-
case 'SUBSCRIPTION':
|
|
17
|
-
return ts.factory.createCallExpression(ts.factory.createIdentifier('useSubscription'), undefined, [
|
|
18
|
-
ts.factory.createIdentifier('executor'),
|
|
19
|
-
ts.factory.createIdentifier(operationName),
|
|
20
|
-
ts.factory.createIdentifier('variables'),
|
|
21
|
-
ts.factory.createIdentifier('requestContext'),
|
|
22
|
-
]);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function generateArrowFunction(operationName, variablesName, resultName, type) {
|
|
26
|
-
const parameters = [];
|
|
27
|
-
let resultType;
|
|
28
|
-
switch (type) {
|
|
29
|
-
case 'LAZY':
|
|
30
|
-
resultType = ts.factory.createTypeReferenceNode('UseLazyOperationReturnType', [
|
|
31
|
-
ts.factory.createTypeReferenceNode(variablesName),
|
|
32
|
-
ts.factory.createTypeReferenceNode(resultName),
|
|
33
|
-
ts.factory.createTypeReferenceNode('TRequestContext'),
|
|
34
|
-
]);
|
|
35
|
-
break;
|
|
36
|
-
case 'SYNC': {
|
|
37
|
-
resultType = ts.factory.createTypeReferenceNode('OperationState', [
|
|
38
|
-
ts.factory.createTypeReferenceNode(resultName),
|
|
39
|
-
]);
|
|
40
|
-
parameters.push(ts.factory.createParameterDeclaration(undefined, undefined, 'variables', undefined, ts.factory.createTypeReferenceNode(variablesName)), ts.factory.createParameterDeclaration(undefined, undefined, 'requestContext', undefined, ts.factory.createTypeReferenceNode('TRequestContext')));
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
case 'SUBSCRIPTION': {
|
|
44
|
-
resultType = ts.factory.createTypeReferenceNode('OperationState', [
|
|
45
|
-
ts.factory.createTypeReferenceNode('SubOpAsyncIterable', [
|
|
46
|
-
ts.factory.createTypeReferenceNode(resultName),
|
|
47
|
-
]),
|
|
48
|
-
]);
|
|
49
|
-
parameters.push(ts.factory.createParameterDeclaration(undefined, undefined, 'variables', undefined, ts.factory.createTypeReferenceNode(variablesName)), ts.factory.createParameterDeclaration(undefined, undefined, 'requestContext', undefined, ts.factory.createTypeReferenceNode('TRequestContext')));
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return ts.factory.createArrowFunction(undefined, undefined, parameters, resultType, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), generateFunctionBlock(operationName, type));
|
|
54
|
-
}
|
|
55
|
-
export function generateNodes(config, context) {
|
|
56
|
-
const graphqlImports = [];
|
|
57
|
-
const queryNodes = [];
|
|
58
|
-
const mutationNodes = [];
|
|
59
|
-
const subscriptionNodes = [];
|
|
60
|
-
for (const operation of Object.values(context.schema.client.operations)) {
|
|
61
|
-
const operationName = operation.name + 'Operation';
|
|
62
|
-
const variablesName = operation.name + 'Variables';
|
|
63
|
-
const resultName = operation.name + 'Result';
|
|
64
|
-
graphqlImports.push(operationName, variablesName, resultName);
|
|
65
|
-
switch (operation.type) {
|
|
66
|
-
case 'SUBSCRIPTION': {
|
|
67
|
-
subscriptionNodes.push(ts.factory.createPropertyAssignment('use' + operation.name, generateArrowFunction(operationName, variablesName, resultName, 'SUBSCRIPTION')));
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
case 'MUTATION': {
|
|
71
|
-
mutationNodes.push(ts.factory.createPropertyAssignment('use' + operation.name, generateArrowFunction(operationName, variablesName, resultName, 'LAZY')));
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
case 'QUERY': {
|
|
75
|
-
queryNodes.push(ts.factory.createPropertyAssignment('use' + operation.name, generateArrowFunction(operationName, variablesName, resultName, 'SYNC')), ts.factory.createPropertyAssignment('useLazy' + operation.name, generateArrowFunction(operationName, variablesName, resultName, 'LAZY')));
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
const gqlClientReactImports = [
|
|
81
|
-
ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('useOperation')),
|
|
82
|
-
ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('useLazyOperation')),
|
|
83
|
-
ts.factory.createImportSpecifier(true, undefined, ts.factory.createIdentifier('OperationState')),
|
|
84
|
-
ts.factory.createImportSpecifier(true, undefined, ts.factory.createIdentifier('UseLazyOperationReturnType')),
|
|
85
|
-
];
|
|
86
|
-
const gqlClientImports = [
|
|
87
|
-
ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('IExecutor')),
|
|
88
|
-
ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('RequestContext')),
|
|
89
|
-
];
|
|
90
|
-
if (subscriptionNodes.length !== 0) {
|
|
91
|
-
gqlClientReactImports.push(ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('useSubscription')));
|
|
92
|
-
gqlClientImports.push(ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('SubOpAsyncIterable')));
|
|
93
|
-
}
|
|
94
|
-
const returnObjectNodes = [];
|
|
95
|
-
if (queryNodes.length !== 0) {
|
|
96
|
-
returnObjectNodes.push(ts.factory.createPropertyAssignment(config.sdk.queriesKey, ts.factory.createObjectLiteralExpression(queryNodes, true)));
|
|
97
|
-
}
|
|
98
|
-
if (mutationNodes.length !== 0) {
|
|
99
|
-
returnObjectNodes.push(ts.factory.createPropertyAssignment(config.sdk.mutationsKey, ts.factory.createObjectLiteralExpression(mutationNodes, true)));
|
|
100
|
-
}
|
|
101
|
-
if (subscriptionNodes.length !== 0) {
|
|
102
|
-
returnObjectNodes.push(ts.factory.createPropertyAssignment(config.sdk.subscriptionsKey, ts.factory.createObjectLiteralExpression(subscriptionNodes, true)));
|
|
103
|
-
}
|
|
104
|
-
return [
|
|
105
|
-
ts.factory.createIdentifier('// @ts-nocheck'),
|
|
106
|
-
...config.importDeclarations,
|
|
107
|
-
ts.factory.createImportDeclaration([], ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports(gqlClientReactImports)), ts.factory.createStringLiteral('@vladimirdev635/gql-client-react')),
|
|
108
|
-
ts.factory.createImportDeclaration([], ts.factory.createImportClause(true, undefined, ts.factory.createNamedImports(gqlClientImports)), ts.factory.createStringLiteral('@vladimirdev635/gql-client/types')),
|
|
109
|
-
ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports(graphqlImports.map((i) => ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier(i))))), ts.factory.createStringLiteral(config.graphqlModulePath)),
|
|
110
|
-
ts.factory.createIdentifier('\n'),
|
|
111
|
-
ts.factory.createFunctionDeclaration(ts.factory.createModifiersFromModifierFlags(ts.ModifierFlags.Export), undefined, 'createSdk', [
|
|
112
|
-
ts.factory.createTypeParameterDeclaration(undefined, 'TRequestContext', ts.factory.createTypeReferenceNode('RequestContext')),
|
|
113
|
-
], [
|
|
114
|
-
ts.factory.createParameterDeclaration(undefined, undefined, 'executor', undefined, ts.factory.createTypeReferenceNode('IExecutor', [
|
|
115
|
-
ts.factory.createTypeReferenceNode('TRequestContext'),
|
|
116
|
-
])),
|
|
117
|
-
], undefined, ts.factory.createBlock([
|
|
118
|
-
ts.factory.createReturnStatement(ts.factory.createObjectLiteralExpression(returnObjectNodes, true)),
|
|
119
|
-
], true)),
|
|
120
|
-
];
|
|
121
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
function generateFunctionBlock(operationName, type) {
|
|
3
|
-
switch (type) {
|
|
4
|
-
case 'SYNC':
|
|
5
|
-
return ts.factory.createCallExpression(ts.factory.createIdentifier('useOperation'), undefined, [
|
|
6
|
-
ts.factory.createIdentifier('executor'),
|
|
7
|
-
ts.factory.createIdentifier(operationName),
|
|
8
|
-
ts.factory.createIdentifier('variables'),
|
|
9
|
-
ts.factory.createIdentifier('requestContext'),
|
|
10
|
-
]);
|
|
11
|
-
case 'LAZY':
|
|
12
|
-
return ts.factory.createCallExpression(ts.factory.createIdentifier('useLazyOperation'), undefined, [
|
|
13
|
-
ts.factory.createIdentifier('executor'),
|
|
14
|
-
ts.factory.createIdentifier(operationName),
|
|
15
|
-
]);
|
|
16
|
-
case 'SUBSCRIPTION':
|
|
17
|
-
return ts.factory.createCallExpression(ts.factory.createIdentifier('useSubscription'), undefined, [
|
|
18
|
-
ts.factory.createIdentifier('executor'),
|
|
19
|
-
ts.factory.createIdentifier(operationName),
|
|
20
|
-
ts.factory.createIdentifier('variables'),
|
|
21
|
-
ts.factory.createIdentifier('requestContext'),
|
|
22
|
-
]);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function createTypeOrRefTypeNode(innerType) {
|
|
26
|
-
return ts.factory.createUnionTypeNode([
|
|
27
|
-
innerType,
|
|
28
|
-
ts.factory.createTypeReferenceNode('Ref', [innerType]),
|
|
29
|
-
]);
|
|
30
|
-
}
|
|
31
|
-
function generateArrowFunction(operationName, variablesName, resultName, type) {
|
|
32
|
-
const parameters = [];
|
|
33
|
-
let resultType;
|
|
34
|
-
switch (type) {
|
|
35
|
-
case 'LAZY':
|
|
36
|
-
resultType = ts.factory.createTypeReferenceNode('UseLazyOperationReturnType', [
|
|
37
|
-
ts.factory.createTypeReferenceNode(variablesName),
|
|
38
|
-
ts.factory.createTypeReferenceNode(resultName),
|
|
39
|
-
ts.factory.createTypeReferenceNode('TRequestContext'),
|
|
40
|
-
]);
|
|
41
|
-
break;
|
|
42
|
-
case 'SYNC': {
|
|
43
|
-
resultType = ts.factory.createTypeReferenceNode('ShallowRef', [
|
|
44
|
-
ts.factory.createTypeReferenceNode('OperationState', [
|
|
45
|
-
ts.factory.createTypeReferenceNode(resultName),
|
|
46
|
-
]),
|
|
47
|
-
]);
|
|
48
|
-
parameters.push(ts.factory.createParameterDeclaration(undefined, undefined, 'variables', undefined, createTypeOrRefTypeNode(ts.factory.createTypeReferenceNode(variablesName))), ts.factory.createParameterDeclaration(undefined, undefined, 'requestContext', undefined, createTypeOrRefTypeNode(ts.factory.createTypeReferenceNode('TRequestContext'))));
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
case 'SUBSCRIPTION': {
|
|
52
|
-
resultType = ts.factory.createTypeReferenceNode('ShallowRef', [
|
|
53
|
-
ts.factory.createTypeReferenceNode('OperationState', [
|
|
54
|
-
ts.factory.createTypeReferenceNode('SubOpAsyncIterable', [
|
|
55
|
-
ts.factory.createTypeReferenceNode(resultName),
|
|
56
|
-
]),
|
|
57
|
-
]),
|
|
58
|
-
]);
|
|
59
|
-
parameters.push(ts.factory.createParameterDeclaration(undefined, undefined, 'variables', undefined, createTypeOrRefTypeNode(ts.factory.createTypeReferenceNode(variablesName))), ts.factory.createParameterDeclaration(undefined, undefined, 'requestContext', undefined, createTypeOrRefTypeNode(ts.factory.createTypeReferenceNode('TRequestContext'))));
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return ts.factory.createArrowFunction(undefined, undefined, parameters, resultType, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), generateFunctionBlock(operationName, type));
|
|
64
|
-
}
|
|
65
|
-
export function generateNodes(config, context) {
|
|
66
|
-
const graphqlImports = [];
|
|
67
|
-
const queryNodes = [];
|
|
68
|
-
const mutationNodes = [];
|
|
69
|
-
const subscriptionNodes = [];
|
|
70
|
-
for (const operation of Object.values(context.schema.client.operations)) {
|
|
71
|
-
const operationName = operation.name + 'Operation';
|
|
72
|
-
const variablesName = operation.name + 'Variables';
|
|
73
|
-
const resultName = operation.name + 'Result';
|
|
74
|
-
graphqlImports.push(operationName, variablesName, resultName);
|
|
75
|
-
switch (operation.type) {
|
|
76
|
-
case 'SUBSCRIPTION': {
|
|
77
|
-
subscriptionNodes.push(ts.factory.createPropertyAssignment('use' + operation.name, generateArrowFunction(operationName, variablesName, resultName, 'SUBSCRIPTION')));
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
case 'MUTATION': {
|
|
81
|
-
mutationNodes.push(ts.factory.createPropertyAssignment('use' + operation.name, generateArrowFunction(operationName, variablesName, resultName, 'LAZY')));
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
case 'QUERY': {
|
|
85
|
-
queryNodes.push(ts.factory.createPropertyAssignment('use' + operation.name, generateArrowFunction(operationName, variablesName, resultName, 'SYNC')), ts.factory.createPropertyAssignment('useLazy' + operation.name, generateArrowFunction(operationName, variablesName, resultName, 'LAZY')));
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
const gqlClientVueImports = [
|
|
91
|
-
ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('useOperation')),
|
|
92
|
-
ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('useLazyOperation')),
|
|
93
|
-
ts.factory.createImportSpecifier(true, undefined, ts.factory.createIdentifier('OperationState')),
|
|
94
|
-
ts.factory.createImportSpecifier(true, undefined, ts.factory.createIdentifier('UseLazyOperationReturnType')),
|
|
95
|
-
];
|
|
96
|
-
const gqlClientImports = [
|
|
97
|
-
ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('IExecutor')),
|
|
98
|
-
ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('RequestContext')),
|
|
99
|
-
];
|
|
100
|
-
if (subscriptionNodes.length !== 0) {
|
|
101
|
-
gqlClientVueImports.push(ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('useSubscription')));
|
|
102
|
-
gqlClientImports.push(ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('SubOpAsyncIterable')));
|
|
103
|
-
}
|
|
104
|
-
const returnObjectNodes = [];
|
|
105
|
-
if (queryNodes.length !== 0) {
|
|
106
|
-
returnObjectNodes.push(ts.factory.createPropertyAssignment(config.sdk.queriesKey, ts.factory.createObjectLiteralExpression(queryNodes, true)));
|
|
107
|
-
}
|
|
108
|
-
if (mutationNodes.length !== 0) {
|
|
109
|
-
returnObjectNodes.push(ts.factory.createPropertyAssignment(config.sdk.mutationsKey, ts.factory.createObjectLiteralExpression(mutationNodes, true)));
|
|
110
|
-
}
|
|
111
|
-
if (subscriptionNodes.length !== 0) {
|
|
112
|
-
returnObjectNodes.push(ts.factory.createPropertyAssignment(config.sdk.subscriptionsKey, ts.factory.createObjectLiteralExpression(subscriptionNodes, true)));
|
|
113
|
-
}
|
|
114
|
-
return [
|
|
115
|
-
ts.factory.createIdentifier('// @ts-nocheck'),
|
|
116
|
-
...config.importDeclarations,
|
|
117
|
-
ts.factory.createImportDeclaration([], ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([
|
|
118
|
-
ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('Ref')),
|
|
119
|
-
ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('ShallowRef')),
|
|
120
|
-
])), ts.factory.createStringLiteral('vue')),
|
|
121
|
-
ts.factory.createImportDeclaration([], ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports(gqlClientVueImports)), ts.factory.createStringLiteral('@vladimirdev635/gql-client-vue')),
|
|
122
|
-
ts.factory.createImportDeclaration([], ts.factory.createImportClause(true, undefined, ts.factory.createNamedImports(gqlClientImports)), ts.factory.createStringLiteral('@vladimirdev635/gql-client/types')),
|
|
123
|
-
ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports(graphqlImports.map((i) => ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier(i))))), ts.factory.createStringLiteral(config.graphqlModulePath)),
|
|
124
|
-
ts.factory.createIdentifier('\n'),
|
|
125
|
-
ts.factory.createFunctionDeclaration(ts.factory.createModifiersFromModifierFlags(ts.ModifierFlags.Export), undefined, 'createSdk', [
|
|
126
|
-
ts.factory.createTypeParameterDeclaration(undefined, 'TRequestContext', ts.factory.createTypeReferenceNode('RequestContext')),
|
|
127
|
-
], [
|
|
128
|
-
ts.factory.createParameterDeclaration(undefined, undefined, 'executor', undefined, ts.factory.createTypeReferenceNode('IExecutor', [
|
|
129
|
-
ts.factory.createTypeReferenceNode('TRequestContext'),
|
|
130
|
-
])),
|
|
131
|
-
], undefined, ts.factory.createBlock([
|
|
132
|
-
ts.factory.createReturnStatement(ts.factory.createObjectLiteralExpression(returnObjectNodes, true)),
|
|
133
|
-
], true)),
|
|
134
|
-
];
|
|
135
|
-
}
|
|
File without changes
|