@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,9 +1,8 @@
|
|
|
1
|
-
/* eslint-disable max-lines */
|
|
2
|
-
import ts from 'typescript';
|
|
3
|
-
import { generateSchemaName, generateZodInferTypeAlias, } from '../server/shared.js';
|
|
4
|
-
import { generateZodObjectFieldSpec } from '../server/objects.js';
|
|
5
1
|
import assert from 'assert';
|
|
2
|
+
import ts from 'typescript';
|
|
6
3
|
import { invokeMethod } from '../../../shared.js';
|
|
4
|
+
import { generateZodObjectFieldSpec } from '../server/objects.js';
|
|
5
|
+
import { generateSchemaName, generateZodInferInterfaceType, generateZodInferTypeAlias, } from '../server/shared.js';
|
|
7
6
|
export function extractFragmentNamesInSpec(schema, fragmentSpec) {
|
|
8
7
|
if (fragmentSpec._type === 'UnionFragmentSpec') {
|
|
9
8
|
return fragmentSpec.selections
|
|
@@ -51,7 +50,7 @@ function generateFragmentDocumentNode(schema, name, fragment) {
|
|
|
51
50
|
].join(' '))),
|
|
52
51
|
], ts.NodeFlags.Const));
|
|
53
52
|
}
|
|
54
|
-
function generateZodObjectSelection(scalarsMapping, schema, objectType, selection, typenameConfig) {
|
|
53
|
+
function generateZodObjectSelection(scalarsMapping, schema, objectType, selection, insideLazy, typenameConfig) {
|
|
55
54
|
switch (selection._type) {
|
|
56
55
|
case 'TypenameField': {
|
|
57
56
|
if ('ignore' in typenameConfig)
|
|
@@ -73,7 +72,7 @@ function generateZodObjectSelection(scalarsMapping, schema, objectType, selectio
|
|
|
73
72
|
!selection.selection.selections.every((s) => s._type === 'TypenameField') ||
|
|
74
73
|
!fieldSpec.nullable;
|
|
75
74
|
// eslint-disable-next-line no-use-before-define
|
|
76
|
-
expression = generateZodFragmentSpecCallExpression(scalarsMapping, schema, selection.selection, { ensurePresent: true, optional });
|
|
75
|
+
expression = generateZodFragmentSpecCallExpression(scalarsMapping, schema, selection.selection, { ensurePresent: true, optional }, insideLazy);
|
|
77
76
|
if (fieldSpec.spec._type === 'array' ||
|
|
78
77
|
(fieldSpec.spec._type === 'callable' &&
|
|
79
78
|
fieldSpec.spec.returnType._type === 'array')) {
|
|
@@ -86,7 +85,14 @@ function generateZodObjectSelection(scalarsMapping, schema, objectType, selectio
|
|
|
86
85
|
return ts.factory.createPropertyAssignment(selection.alias, expression);
|
|
87
86
|
}
|
|
88
87
|
case 'SpreadSelection': {
|
|
89
|
-
|
|
88
|
+
const schemaName = generateSchemaName(selection.fragment + 'Fragment');
|
|
89
|
+
const expressionForShape = insideLazy
|
|
90
|
+
? ts.factory.createIdentifier(schemaName)
|
|
91
|
+
: ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createPropertyAccessExpression(ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), ts.factory.createIdentifier('lazy')), undefined, [
|
|
92
|
+
ts.factory.createArrowFunction(undefined, undefined, [], undefined, ts.factory.createToken(ts.SyntaxKind
|
|
93
|
+
.EqualsGreaterThanToken), ts.factory.createIdentifier(schemaName)),
|
|
94
|
+
]), ts.factory.createIdentifier('def')), ts.factory.createIdentifier('getter')), undefined, []);
|
|
95
|
+
return ts.factory.createSpreadAssignment(ts.factory.createPropertyAccessExpression(expressionForShape, ts.factory.createIdentifier('shape')));
|
|
90
96
|
}
|
|
91
97
|
}
|
|
92
98
|
}
|
|
@@ -113,17 +119,10 @@ function generateZodObjectFragmentSpecCallExpression(scalarsMapping, schema, obj
|
|
|
113
119
|
const selections = resolveSelections(specSelections, typenameConfig);
|
|
114
120
|
const expression = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), 'object'), undefined, [
|
|
115
121
|
ts.factory.createObjectLiteralExpression(selections
|
|
116
|
-
.map((s) => generateZodObjectSelection(scalarsMapping, schema, object, s, typenameConfig))
|
|
122
|
+
.map((s) => generateZodObjectSelection(scalarsMapping, schema, object, s, insideLazy, typenameConfig))
|
|
117
123
|
.filter((s) => s !== null), true),
|
|
118
124
|
]);
|
|
119
|
-
|
|
120
|
-
return expression;
|
|
121
|
-
const hasSpreadSelection = selections.some((s) => s._type === 'SpreadSelection');
|
|
122
|
-
if (!hasSpreadSelection)
|
|
123
|
-
return expression;
|
|
124
|
-
return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), 'lazy'), undefined, [
|
|
125
|
-
ts.factory.createArrowFunction(undefined, undefined, [], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), expression),
|
|
126
|
-
]);
|
|
125
|
+
return expression;
|
|
127
126
|
}
|
|
128
127
|
function resolveUnionSelections(schema, specSelections) {
|
|
129
128
|
const typenameSelections = [];
|
|
@@ -145,7 +144,7 @@ function resolveUnionSelections(schema, specSelections) {
|
|
|
145
144
|
.flat();
|
|
146
145
|
return [objectSelections, typenameSelections];
|
|
147
146
|
}
|
|
148
|
-
function generateZodUnionFragmentSpecCallExpression(scalarsMapping, schema, spec) {
|
|
147
|
+
function generateZodUnionFragmentSpecCallExpression(scalarsMapping, schema, spec, insideLazy) {
|
|
149
148
|
const [objectSelections, typenameSelections] = resolveUnionSelections(schema, spec.selections);
|
|
150
149
|
for (const item of Object.keys(schema.server.unions[spec.name].items)) {
|
|
151
150
|
if (!objectSelections.some((s) => s.object === item)) {
|
|
@@ -163,15 +162,17 @@ function generateZodUnionFragmentSpecCallExpression(scalarsMapping, schema, spec
|
|
|
163
162
|
const expression = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), 'union'), undefined, [
|
|
164
163
|
ts.factory.createArrayLiteralExpression(objectSelections.map((s) => generateZodObjectFragmentSpecCallExpression(scalarsMapping, schema, schema.server.objects[s.object], [...s.spec.selections, ...typenameSelections], true, { ensurePresent: true, optional: false })), true),
|
|
165
164
|
]);
|
|
165
|
+
if (insideLazy)
|
|
166
|
+
return expression;
|
|
166
167
|
return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), 'lazy'), undefined, [
|
|
167
168
|
ts.factory.createArrowFunction(undefined, undefined, [], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), expression),
|
|
168
169
|
]);
|
|
169
170
|
}
|
|
170
|
-
export function generateZodFragmentSpecCallExpression(scalarsMapping, schema, spec, typenameConfig) {
|
|
171
|
+
export function generateZodFragmentSpecCallExpression(scalarsMapping, schema, spec, typenameConfig, insideLazy = false) {
|
|
171
172
|
if (spec._type === 'ObjectFragmentSpec') {
|
|
172
|
-
return generateZodObjectFragmentSpecCallExpression(scalarsMapping, schema, schema.server.objects[spec.name], spec.selections,
|
|
173
|
+
return generateZodObjectFragmentSpecCallExpression(scalarsMapping, schema, schema.server.objects[spec.name], spec.selections, insideLazy, typenameConfig || { ensurePresent: true, optional: true });
|
|
173
174
|
}
|
|
174
|
-
return generateZodUnionFragmentSpecCallExpression(scalarsMapping, schema, spec);
|
|
175
|
+
return generateZodUnionFragmentSpecCallExpression(scalarsMapping, schema, spec, insideLazy);
|
|
175
176
|
}
|
|
176
177
|
function generateZodFragmentSchema(scalarsMapping, schema, fragmentName, fragment) {
|
|
177
178
|
return ts.factory.createVariableStatement([ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], ts.factory.createVariableDeclarationList([
|
|
@@ -183,7 +184,9 @@ function generateFragmentSpecDeclarations(scalarsMapping, schema, fragmentName,
|
|
|
183
184
|
return [
|
|
184
185
|
generateFragmentDocumentNode(schema, fragmentName, fragment),
|
|
185
186
|
generateZodFragmentSchema(scalarsMapping, schema, fragmentName, fragment),
|
|
186
|
-
|
|
187
|
+
fragment.spec._type === 'ObjectFragmentSpec'
|
|
188
|
+
? generateZodInferInterfaceType('output', fName, generateSchemaName(fName))
|
|
189
|
+
: generateZodInferTypeAlias('output', fName, generateSchemaName(fName)),
|
|
187
190
|
];
|
|
188
191
|
}
|
|
189
192
|
export function generateFragmentTypes(scalarsMapping, schema) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
1
|
import { ActorContext } from '../../../../../config.js';
|
|
3
|
-
import
|
|
4
|
-
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
import { Config } from '../../actor.js';
|
|
4
|
+
export declare function generateClientNodes(config: Config, context: ActorContext): ts.Node[];
|
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
1
|
import { generateFragmentTypes } from './fragments.js';
|
|
3
2
|
import { generateOperationsNodes } from './operations.js';
|
|
4
|
-
const operationTypeNode = ts.factory.createInterfaceDeclaration(ts.factory.createModifiersFromModifierFlags(ts.ModifierFlags.Export), 'Operation', [
|
|
5
|
-
ts.factory.createTypeParameterDeclaration(undefined, 'V'),
|
|
6
|
-
ts.factory.createTypeParameterDeclaration(undefined, 'R'),
|
|
7
|
-
], [], [
|
|
8
|
-
ts.factory.createPropertySignature(undefined, 'name', undefined, ts.factory.createTypeReferenceNode('string')),
|
|
9
|
-
ts.factory.createPropertySignature(undefined, 'type', undefined, ts.factory.createUnionTypeNode(['QUERY', 'MUTATION', 'SUBSCRIPTION'].map((v) => ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(v))))),
|
|
10
|
-
ts.factory.createPropertySignature(undefined, 'document', undefined, ts.factory.createTypeReferenceNode('string')),
|
|
11
|
-
ts.factory.createPropertySignature(undefined, 'variablesSchema', undefined, ts.factory.createTypeReferenceNode('z.ZodType', [
|
|
12
|
-
ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword),
|
|
13
|
-
ts.factory.createTypeReferenceNode('V'),
|
|
14
|
-
])),
|
|
15
|
-
ts.factory.createPropertySignature(undefined, 'resultSchema', undefined, ts.factory.createTypeReferenceNode('z.ZodType', [
|
|
16
|
-
ts.factory.createTypeReferenceNode('R'),
|
|
17
|
-
])),
|
|
18
|
-
]);
|
|
19
3
|
export function generateClientNodes(config, context) {
|
|
20
4
|
return [
|
|
21
|
-
operationTypeNode,
|
|
22
5
|
...generateFragmentTypes(config.scalarsMapping, context.schema),
|
|
23
|
-
...generateOperationsNodes(config.scalarsMapping, context.schema),
|
|
6
|
+
...generateOperationsNodes(config.clientTypeNameBuilders, config.scalarsMapping, context.schema),
|
|
24
7
|
];
|
|
25
8
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { RootSchema } from '../../../../../schema/root.js';
|
|
1
|
+
import { ClientTypeNameBuilders } from '../../../../../actors/ts/shared.js';
|
|
3
2
|
import { operationSchema } from '../../../../../schema/client/operation.js';
|
|
3
|
+
import { RootSchema } from '../../../../../schema/root.js';
|
|
4
|
+
import ts from 'typescript';
|
|
4
5
|
import { z } from 'zod/v4';
|
|
5
6
|
import { ScalarsMapping } from '../server/scalars/mapping.js';
|
|
6
7
|
export declare function opTypeToName(type: z.infer<typeof operationSchema>['type']): string;
|
|
7
|
-
export declare function generateOperationsNodes(scalarsMapping: ScalarsMapping, schema: RootSchema): ts.Node[];
|
|
8
|
+
export declare function generateOperationsNodes(clientTypeNameBuilders: ClientTypeNameBuilders, scalarsMapping: ScalarsMapping, schema: RootSchema): ts.Node[];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/* eslint-disable max-lines */
|
|
2
1
|
import ts from 'typescript';
|
|
3
|
-
import { extractFragmentSourceTextsInSpec, generateZodFragmentSpecCallExpression, } from './fragments.js';
|
|
4
|
-
import { generateSchemaName, generateZodInferTypeAlias, } from '../server/shared.js';
|
|
5
2
|
import { generateInputTypeDefinitionFields } from '../server/inputs.js';
|
|
3
|
+
import { generateSchemaName, generateZodInferInterfaceType, } from '../server/shared.js';
|
|
4
|
+
import { extractFragmentSourceTextsInSpec, generateZodFragmentSpecCallExpression, } from './fragments.js';
|
|
6
5
|
export function opTypeToName(type) {
|
|
7
6
|
switch (type) {
|
|
8
7
|
case 'QUERY':
|
|
@@ -19,50 +18,49 @@ function parametersToFields(parameters) {
|
|
|
19
18
|
parameters[name],
|
|
20
19
|
]));
|
|
21
20
|
}
|
|
22
|
-
function generateOperationNode(schema, operation) {
|
|
21
|
+
function generateOperationNode(clientTypeNameBuilders, schema, operation) {
|
|
23
22
|
return ts.factory.createVariableStatement(ts.factory.createModifiersFromModifierFlags(ts.ModifierFlags.Export), ts.factory.createVariableDeclarationList([
|
|
24
|
-
ts.factory.createVariableDeclaration(ts.factory.createIdentifier(operation.name
|
|
23
|
+
ts.factory.createVariableDeclaration(ts.factory.createIdentifier(clientTypeNameBuilders.operationTypeName(operation.name)), undefined, undefined, ts.factory.createAsExpression(ts.factory.createObjectLiteralExpression([
|
|
25
24
|
ts.factory.createPropertyAssignment('name', ts.factory.createStringLiteral(operation.name)),
|
|
26
25
|
ts.factory.createPropertyAssignment('type', ts.factory.createStringLiteral(operation.type)),
|
|
27
26
|
ts.factory.createPropertyAssignment('document', ts.factory.createStringLiteral([
|
|
28
27
|
operation.sourceText,
|
|
29
28
|
...extractFragmentSourceTextsInSpec(schema, operation.fragmentSpec),
|
|
30
29
|
].join(' '))),
|
|
31
|
-
ts.factory.createPropertyAssignment('variablesSchema', ts.factory.createIdentifier(generateSchemaName(operation.name
|
|
32
|
-
ts.factory.createPropertyAssignment('resultSchema', ts.factory.createIdentifier(generateSchemaName(operation.name
|
|
33
|
-
], true), ts.factory.createTypeReferenceNode('const')),
|
|
34
|
-
ts.factory.createTypeReferenceNode(operation.name + 'Variables'),
|
|
35
|
-
ts.factory.createTypeReferenceNode(operation.name + 'Result'),
|
|
36
|
-
]))),
|
|
30
|
+
ts.factory.createPropertyAssignment('variablesSchema', ts.factory.createIdentifier(generateSchemaName(clientTypeNameBuilders.variablesTypeName(operation.name)))),
|
|
31
|
+
ts.factory.createPropertyAssignment('resultSchema', ts.factory.createIdentifier(generateSchemaName(clientTypeNameBuilders.resultTypeName(operation.name)))),
|
|
32
|
+
], true), ts.factory.createTypeReferenceNode('const'))),
|
|
37
33
|
], ts.NodeFlags.Const));
|
|
38
34
|
}
|
|
39
|
-
function generateOperationZodInputSchema(scalarsMapping, operation) {
|
|
35
|
+
function generateOperationZodInputSchema(scalarsMapping, operation, variablesName) {
|
|
40
36
|
return ts.factory.createVariableStatement([ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], ts.factory.createVariableDeclarationList([
|
|
41
|
-
ts.factory.createVariableDeclaration(ts.factory.createIdentifier(generateSchemaName(
|
|
42
|
-
ts.factory.createObjectLiteralExpression(generateInputTypeDefinitionFields(scalarsMapping, parametersToFields(operation.parameters)), true),
|
|
37
|
+
ts.factory.createVariableDeclaration(ts.factory.createIdentifier(generateSchemaName(variablesName)), undefined, undefined, ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), 'object'), undefined, [
|
|
38
|
+
ts.factory.createObjectLiteralExpression(generateInputTypeDefinitionFields(scalarsMapping, parametersToFields(operation.parameters), true), true),
|
|
43
39
|
])),
|
|
44
40
|
], ts.NodeFlags.Const));
|
|
45
41
|
}
|
|
46
|
-
function genearteOperationZodOutputSchema(scalarsMapping, schema, operation) {
|
|
42
|
+
function genearteOperationZodOutputSchema(scalarsMapping, schema, operation, resultName) {
|
|
47
43
|
return ts.factory.createVariableStatement([ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], ts.factory.createVariableDeclarationList([
|
|
48
|
-
ts.factory.createVariableDeclaration(ts.factory.createIdentifier(generateSchemaName(
|
|
44
|
+
ts.factory.createVariableDeclaration(ts.factory.createIdentifier(generateSchemaName(resultName)), undefined, undefined, generateZodFragmentSpecCallExpression(scalarsMapping, schema, operation.fragmentSpec, undefined, true)),
|
|
49
45
|
], ts.NodeFlags.Const));
|
|
50
46
|
}
|
|
51
|
-
function generateOperationNodes(scalarsMapping, schema, operation) {
|
|
47
|
+
function generateOperationNodes(clientTypeNameBuilders, scalarsMapping, schema, operation) {
|
|
48
|
+
const variablesName = clientTypeNameBuilders.variablesTypeName(operation.name);
|
|
49
|
+
const resultName = clientTypeNameBuilders.resultTypeName(operation.name);
|
|
52
50
|
return [
|
|
53
|
-
generateOperationZodInputSchema(scalarsMapping, operation),
|
|
54
|
-
|
|
51
|
+
generateOperationZodInputSchema(scalarsMapping, operation, variablesName),
|
|
52
|
+
generateZodInferInterfaceType('input', variablesName, generateSchemaName(variablesName)),
|
|
55
53
|
ts.factory.createIdentifier('\n'),
|
|
56
|
-
genearteOperationZodOutputSchema(scalarsMapping, schema, operation),
|
|
57
|
-
|
|
58
|
-
generateOperationNode(schema, operation),
|
|
54
|
+
genearteOperationZodOutputSchema(scalarsMapping, schema, operation, resultName),
|
|
55
|
+
generateZodInferInterfaceType('output', resultName, generateSchemaName(resultName)),
|
|
56
|
+
generateOperationNode(clientTypeNameBuilders, schema, operation),
|
|
59
57
|
ts.factory.createIdentifier('\n'),
|
|
60
58
|
];
|
|
61
59
|
}
|
|
62
|
-
export function generateOperationsNodes(scalarsMapping, schema) {
|
|
60
|
+
export function generateOperationsNodes(clientTypeNameBuilders, scalarsMapping, schema) {
|
|
63
61
|
return Object.values(schema.client.operations)
|
|
64
62
|
.map((operation) => {
|
|
65
|
-
return generateOperationNodes(scalarsMapping, schema, operation);
|
|
63
|
+
return generateOperationNodes(clientTypeNameBuilders, scalarsMapping, schema, operation);
|
|
66
64
|
})
|
|
67
65
|
.flat();
|
|
68
66
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { ActorContext } from '../../../../config.js';
|
|
3
|
-
import {
|
|
4
|
-
export declare function generateNodes(config:
|
|
3
|
+
import { Config } from '../actor.js';
|
|
4
|
+
export declare function generateNodes(config: Config, context: ActorContext): ts.Node[];
|
|
@@ -3,7 +3,7 @@ import { generateServerNodes } from './server/main.js';
|
|
|
3
3
|
import { generateClientNodes } from './client/main.js';
|
|
4
4
|
export function generateNodes(config, context) {
|
|
5
5
|
return [
|
|
6
|
-
ts.factory.createImportDeclaration([], ts.factory.createImportClause(
|
|
6
|
+
ts.factory.createImportDeclaration([], ts.factory.createImportClause(undefined, undefined, ts.factory.createNamedImports([
|
|
7
7
|
ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('z')),
|
|
8
8
|
])), ts.factory.createStringLiteral('zod/v4')),
|
|
9
9
|
...config.importDeclarations,
|
|
@@ -3,5 +3,5 @@ import ts from 'typescript';
|
|
|
3
3
|
import { inputSchema } from '../../../../../schema/server.js';
|
|
4
4
|
import { inputFieldSchema } from '../../../../../schema/shared.js';
|
|
5
5
|
import { ScalarsMapping } from './scalars/index.js';
|
|
6
|
-
export declare function generateInputTypeDefinitionFields(scalarsMapping: ScalarsMapping, fields: Record<string, z.infer<typeof inputFieldSchema
|
|
6
|
+
export declare function generateInputTypeDefinitionFields(scalarsMapping: ScalarsMapping, fields: Record<string, z.infer<typeof inputFieldSchema>>, insideLazy: boolean): (ts.PropertyAssignment | ts.GetAccessorDeclaration)[];
|
|
7
7
|
export declare function generateInputTypeDefinitions(scalarsMapping: ScalarsMapping, input: z.infer<typeof inputSchema>): ts.Node[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { getScalarSpecFromMapping } from './scalars/index.js';
|
|
3
3
|
import { invokeMethod } from '../../../shared.js';
|
|
4
|
-
import { generateSchemaName,
|
|
4
|
+
import { generateSchemaName, generateZodInferInterfaceType } from './shared.js';
|
|
5
5
|
function generateZodInputTypeSpec(scalarsMapping, type) {
|
|
6
6
|
switch (type._type) {
|
|
7
7
|
case 'Enum': {
|
|
@@ -41,26 +41,26 @@ function isFieldLazy(spec) {
|
|
|
41
41
|
return isFieldLazy(spec.type);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
export function generateInputTypeDefinitionFields(scalarsMapping, fields) {
|
|
44
|
+
export function generateInputTypeDefinitionFields(scalarsMapping, fields, insideLazy) {
|
|
45
45
|
return Object.entries(fields).map(([name, field]) => {
|
|
46
46
|
const fieldSpec = generateZodInputField(scalarsMapping, field);
|
|
47
|
-
if (isFieldLazy(field.spec)) {
|
|
47
|
+
if (isFieldLazy(field.spec) && !insideLazy) {
|
|
48
48
|
return ts.factory.createGetAccessorDeclaration([], name, [], undefined, ts.factory.createBlock([ts.factory.createReturnStatement(fieldSpec)], true));
|
|
49
49
|
}
|
|
50
50
|
return ts.factory.createPropertyAssignment(name, fieldSpec);
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
function generateZodInputTypeDefinition(scalarsMapping, name, fields) {
|
|
53
|
+
function generateZodInputTypeDefinition(scalarsMapping, name, fields, insideLazy = false) {
|
|
54
54
|
return ts.factory.createVariableStatement([ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], ts.factory.createVariableDeclarationList([
|
|
55
55
|
ts.factory.createVariableDeclaration(generateSchemaName(name), undefined, undefined, ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), ts.factory.createIdentifier('object')), undefined, [
|
|
56
|
-
ts.factory.createObjectLiteralExpression(generateInputTypeDefinitionFields(scalarsMapping, fields), true),
|
|
56
|
+
ts.factory.createObjectLiteralExpression(generateInputTypeDefinitionFields(scalarsMapping, fields, insideLazy), true),
|
|
57
57
|
])),
|
|
58
58
|
], ts.NodeFlags.Const));
|
|
59
59
|
}
|
|
60
60
|
export function generateInputTypeDefinitions(scalarsMapping, input) {
|
|
61
61
|
return [
|
|
62
62
|
generateZodInputTypeDefinition(scalarsMapping, input.name, input.fields),
|
|
63
|
-
|
|
63
|
+
generateZodInferInterfaceType('input', input.name, generateSchemaName(input.name)),
|
|
64
64
|
ts.factory.createIdentifier('\n'),
|
|
65
65
|
];
|
|
66
66
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import {
|
|
2
|
+
import { Config } from '../../actor.js';
|
|
3
3
|
import { ActorContext } from '../../../../../config.js';
|
|
4
|
-
export declare function generateServerNodes(config:
|
|
4
|
+
export declare function generateServerNodes(config: Config, context: ActorContext): ts.Node[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
2
|
import { getScalarSpecFromMapping } from './scalars/mapping.js';
|
|
3
3
|
import ts from 'typescript';
|
|
4
|
-
import { generateSchemaName,
|
|
4
|
+
import { generateSchemaName, generateZodInferInterfaceType } from './shared.js';
|
|
5
5
|
import { assertUnreachable } from '../../../../../utils.js';
|
|
6
6
|
import { invokeMethod } from '../../../shared.js';
|
|
7
7
|
function generateZodObjectTypeSpec(scalarsMapping, type) {
|
|
@@ -101,7 +101,7 @@ export function generateZodObjectTypeNode(scalarsMapping, object) {
|
|
|
101
101
|
export function generateObjectTypeNodes(scalarsMapping, object) {
|
|
102
102
|
return [
|
|
103
103
|
generateZodObjectTypeNode(scalarsMapping, object),
|
|
104
|
-
|
|
104
|
+
generateZodInferInterfaceType('output', object.name, generateSchemaName(object.name)),
|
|
105
105
|
ts.factory.createIdentifier('\n'),
|
|
106
106
|
];
|
|
107
107
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
2
|
import ts from 'typescript';
|
|
3
|
-
import { buildSymmetricScalarSpec } from './mapping.js';
|
|
4
3
|
import { invokeMethod } from '../../../../shared.js';
|
|
5
4
|
import { builtinScalarsMapping } from './builtin.js';
|
|
5
|
+
import { buildSymmetricScalarSpec } from './mapping.js';
|
|
6
6
|
export const additionalScalarsMapping = {
|
|
7
7
|
Int64: builtinScalarsMapping.Int,
|
|
8
8
|
UUID: builtinScalarsMapping.String,
|
|
@@ -40,4 +40,5 @@ export const additionalScalarsMapping = {
|
|
|
40
40
|
], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createNewExpression(ts.factory.createIdentifier('Date'), [], [ts.factory.createIdentifier('v')])),
|
|
41
41
|
]),
|
|
42
42
|
},
|
|
43
|
+
Duration: buildSymmetricScalarSpec(ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), 'iso'), 'duration'), undefined, [])),
|
|
43
44
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
import { z } from 'zod/v4';
|
|
3
1
|
import { objectNonCallableFieldSpecSchema } from '../../../../../schema/server.js';
|
|
4
2
|
import { inputFieldSpecSchema } from '../../../../../schema/shared.js';
|
|
3
|
+
import ts from 'typescript';
|
|
4
|
+
import { z } from 'zod/v4';
|
|
5
5
|
export declare function generateNonCallableFieldSpec(scalars: string[], spec: z.infer<typeof objectNonCallableFieldSpecSchema> | z.infer<typeof inputFieldSpecSchema>): ts.TypeNode;
|
|
6
6
|
export declare function wrapInMaybeIfNullable(spec: ts.TypeNode, nullable: boolean): ts.TypeNode;
|
|
7
7
|
export declare function generateZodInferTypeAlias(inferType: 'input' | 'output', name: string, typeName: string): ts.TypeAliasDeclaration;
|
|
8
|
+
export declare function generateZodInferInterfaceType(inferType: 'input' | 'output', name: string, typeName: string): ts.InterfaceDeclaration;
|
|
8
9
|
export declare function generateSchemaName(name: string): string;
|
|
@@ -14,10 +14,19 @@ export function wrapInMaybeIfNullable(spec, nullable) {
|
|
|
14
14
|
: spec;
|
|
15
15
|
}
|
|
16
16
|
export function generateZodInferTypeAlias(inferType, name, typeName) {
|
|
17
|
-
return ts.factory.createTypeAliasDeclaration(ts.factory.createModifiersFromModifierFlags(ts.ModifierFlags.Export), name, undefined, ts.factory.
|
|
17
|
+
return ts.factory.createTypeAliasDeclaration(ts.factory.createModifiersFromModifierFlags(ts.ModifierFlags.Export), name, undefined, ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier('z.' + inferType), [
|
|
18
18
|
ts.factory.createTypeQueryNode(ts.factory.createIdentifier(typeName), undefined),
|
|
19
19
|
]));
|
|
20
20
|
}
|
|
21
|
+
export function generateZodInferInterfaceType(inferType, name, typeName) {
|
|
22
|
+
return ts.factory.createInterfaceDeclaration(ts.factory.createModifiersFromModifierFlags(ts.ModifierFlags.Export), name, undefined, [
|
|
23
|
+
ts.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [
|
|
24
|
+
ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier('z.' + inferType), [
|
|
25
|
+
ts.factory.createTypeQueryNode(ts.factory.createIdentifier(typeName), undefined),
|
|
26
|
+
]),
|
|
27
|
+
]),
|
|
28
|
+
], []);
|
|
29
|
+
}
|
|
21
30
|
export function generateSchemaName(name) {
|
|
22
31
|
return name[0].toLowerCase() + name.slice(1) + 'Schema';
|
|
23
32
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { generateSchemaName,
|
|
2
|
+
import { generateSchemaName, generateZodInferInterfaceType } from './shared.js';
|
|
3
3
|
import { generateZodObjectTypeExpression } from './objects.js';
|
|
4
4
|
function generateZodUnionTypeNode(scalarsMapping, objects, union) {
|
|
5
5
|
return ts.factory.createVariableStatement([ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], ts.factory.createVariableDeclarationList([
|
|
@@ -12,7 +12,7 @@ function generateZodUnionTypeNode(scalarsMapping, objects, union) {
|
|
|
12
12
|
export function generateUnionTypeDefinitions(scalarsMapping, objects, union) {
|
|
13
13
|
return [
|
|
14
14
|
generateZodUnionTypeNode(scalarsMapping, objects, union),
|
|
15
|
-
|
|
15
|
+
generateZodInferInterfaceType('output', union.name, generateSchemaName(union.name)),
|
|
16
16
|
ts.factory.createIdentifier('\n'),
|
|
17
17
|
];
|
|
18
18
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { build, Config } from './actor.js';
|
|
2
2
|
export { builtinScalarsMapping, additionalScalarsMapping, type BuiltinScalarName, type ScalarSpec, type ScalarsMapping, buildSymmetricScalarSpec, getScalarSpecFromMapping, } from './generators/server/scalars/index.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { build } from './actor.js';
|
|
2
2
|
export { builtinScalarsMapping, additionalScalarsMapping, buildSymmetricScalarSpec, getScalarSpecFromMapping, } from './generators/server/scalars/index.js';
|
package/actors/ts/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * as gqlClient from './gql-client/index.js';
|
|
2
2
|
export * as gqlClientReact from './gql-client-react/index.js';
|
|
3
3
|
export * as gqlClientVue from './gql-client-vue/index.js';
|
|
4
|
+
export * as gqlClientFramework from './gql-client-framework/index.js';
|
|
4
5
|
export * as graphql from './graphql/index.js';
|
|
5
|
-
export { type Formatter, type TSActorConfig, renderNodes, loadTsConfigCompilerOptions, addNewLineBetweenNodes, invokeMethod, } from './shared.js';
|
|
6
|
+
export { type Formatter, type TSActorConfig, type ClientTypeNameBuilders, renderNodes, loadTsConfigCompilerOptions, addNewLineBetweenNodes, invokeMethod, } from './shared.js';
|
|
6
7
|
export { generateImportDeclaration } from './utils.js';
|
|
7
8
|
export * as formatters from './formatters/index.js';
|
package/actors/ts/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * as gqlClient from './gql-client/index.js';
|
|
2
2
|
export * as gqlClientReact from './gql-client-react/index.js';
|
|
3
3
|
export * as gqlClientVue from './gql-client-vue/index.js';
|
|
4
|
+
export * as gqlClientFramework from './gql-client-framework/index.js';
|
|
4
5
|
export * as graphql from './graphql/index.js';
|
|
5
6
|
export { renderNodes, loadTsConfigCompilerOptions, addNewLineBetweenNodes, invokeMethod, } from './shared.js';
|
|
6
7
|
export { generateImportDeclaration } from './utils.js';
|
package/actors/ts/shared.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
+
export interface ClientTypeNameBuilders {
|
|
3
|
+
operationTypeName: (operationName: string) => string;
|
|
4
|
+
variablesTypeName: (operationName: string) => string;
|
|
5
|
+
resultTypeName: (operationName: string) => string;
|
|
6
|
+
}
|
|
2
7
|
export type Formatter = (code: string) => Promise<string> | string;
|
|
3
8
|
export interface TSActorConfig {
|
|
4
9
|
tsconfigCompilerOptions: ts.CompilerOptions;
|
package/actors/ts/utils.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
export declare function
|
|
3
|
-
|
|
4
|
-
alias: string;
|
|
5
|
-
})[]): ts.ImportDeclaration;
|
|
2
|
+
export declare function generateImportSpecifier(name: string, typeOnly?: boolean, alias?: string | null): ts.ImportSpecifier;
|
|
3
|
+
export declare function generateImportDeclaration(modulePath: string, imports: ts.ImportSpecifier[]): ts.ImportDeclaration;
|
package/actors/ts/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
+
export function generateImportSpecifier(name, typeOnly = false, alias = null) {
|
|
3
|
+
return ts.factory.createImportSpecifier(typeOnly, alias === null ? undefined : ts.factory.createIdentifier(alias), ts.factory.createIdentifier(name));
|
|
4
|
+
}
|
|
2
5
|
export function generateImportDeclaration(modulePath, imports) {
|
|
3
|
-
return ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports(imports
|
|
4
|
-
? undefined
|
|
5
|
-
: ts.factory.createIdentifier(i.alias), ts.factory.createIdentifier(typeof i === 'string' ? i : i.name))))), ts.factory.createStringLiteral(modulePath));
|
|
6
|
+
return ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports(imports)), ts.factory.createStringLiteral(modulePath));
|
|
6
7
|
}
|
package/package.json
CHANGED
package/schema/utils.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { PathOrFileDescriptor } from 'fs';
|
|
2
|
-
import { objectFieldSchema, objectFieldSpecSchema, objectSchema, ServerSchema, unionSchema } from './server.js';
|
|
3
|
-
import { ClientSchema } from './client/root.js';
|
|
4
2
|
import { z } from 'zod/v4';
|
|
5
|
-
import { RootSchema } from './root.js';
|
|
6
|
-
import { fieldSelection, fragmentSchema, fragmentSpecSchema } from './client/fragment.js';
|
|
7
3
|
import { argument } from './client/argument.js';
|
|
4
|
+
import { fieldSelection, fragmentSchema, fragmentSpecSchema } from './client/fragment.js';
|
|
5
|
+
import { ClientSchema } from './client/root.js';
|
|
6
|
+
import { RootSchema } from './root.js';
|
|
7
|
+
import { objectFieldSchema, objectFieldSpecSchema, objectSchema, ServerSchema, unionSchema } from './server.js';
|
|
8
8
|
export declare function loadSchemaFromFile<T extends z.ZodType>(p: PathOrFileDescriptor, schema: T): z.infer<T>;
|
|
9
9
|
export declare function loadServerSchemaFromFile(p: PathOrFileDescriptor): ServerSchema;
|
|
10
10
|
export declare function loadClientSchemaFromFile(p: PathOrFileDescriptor): ClientSchema;
|
|
11
|
-
export declare function loadServerSchemaFromGQLSubprocess(gqlPath?: string, gqlArgs?: string[]): Promise<ServerSchema>;
|
|
12
|
-
export declare function loadRootSchemaFromGQLSubprocess(gqlPath?: string, gqlArgs?: string[]): Promise<RootSchema>;
|
|
11
|
+
export declare function loadServerSchemaFromGQLSubprocess(gqlPath?: string, gqlArgs?: string[], maxBuffer?: number | undefined): Promise<ServerSchema>;
|
|
12
|
+
export declare function loadRootSchemaFromGQLSubprocess(gqlPath?: string, gqlArgs?: string[], maxBuffer?: number | undefined): Promise<RootSchema>;
|
|
13
13
|
export declare function buildFragmentFromUnion(union: z.infer<typeof unionSchema>): z.infer<typeof fragmentSchema>;
|
|
14
14
|
export declare function buildSelectionFromFieldSpec(spec: z.infer<typeof objectFieldSpecSchema>): z.infer<typeof fragmentSpecSchema> | null;
|
|
15
15
|
export declare function buildArgumentFromFieldSpec(spec: z.infer<typeof objectFieldSpecSchema>): Record<string, z.infer<typeof argument>>;
|
package/schema/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
2
|
import { readFileSync } from 'fs';
|
|
3
|
-
import { serverSchema, } from './server.js';
|
|
4
|
-
import { clientSchema } from './client/root.js';
|
|
5
3
|
import { exec } from 'node:child_process';
|
|
4
|
+
import { clientSchema } from './client/root.js';
|
|
5
|
+
import { serverSchema, } from './server.js';
|
|
6
6
|
export function loadSchemaFromFile(p, schema) {
|
|
7
7
|
return schema.parse(JSON.parse(readFileSync(p).toString()));
|
|
8
8
|
}
|
|
@@ -12,9 +12,11 @@ export function loadServerSchemaFromFile(p) {
|
|
|
12
12
|
export function loadClientSchemaFromFile(p) {
|
|
13
13
|
return loadSchemaFromFile(p, clientSchema);
|
|
14
14
|
}
|
|
15
|
-
export async function loadServerSchemaFromGQLSubprocess(gqlPath = 'gql', gqlArgs = ['generate']) {
|
|
15
|
+
export async function loadServerSchemaFromGQLSubprocess(gqlPath = 'gql', gqlArgs = ['generate'], maxBuffer = undefined) {
|
|
16
16
|
const output = await new Promise((resolve, reject) => {
|
|
17
|
-
exec([gqlPath, ...gqlArgs].join(' '),
|
|
17
|
+
exec([gqlPath, ...gqlArgs].join(' '), {
|
|
18
|
+
maxBuffer,
|
|
19
|
+
}, (err, stdout, stderr) => {
|
|
18
20
|
if (err !== null) {
|
|
19
21
|
reject(err);
|
|
20
22
|
}
|
|
@@ -26,9 +28,9 @@ export async function loadServerSchemaFromGQLSubprocess(gqlPath = 'gql', gqlArgs
|
|
|
26
28
|
});
|
|
27
29
|
return serverSchema.parse(JSON.parse(output));
|
|
28
30
|
}
|
|
29
|
-
export async function loadRootSchemaFromGQLSubprocess(gqlPath = 'gql', gqlArgs = ['generate']) {
|
|
31
|
+
export async function loadRootSchemaFromGQLSubprocess(gqlPath = 'gql', gqlArgs = ['generate'], maxBuffer = undefined) {
|
|
30
32
|
const output = await new Promise((resolve, reject) => {
|
|
31
|
-
exec([gqlPath, ...gqlArgs].join(' '), (err, stdout, stderr) => {
|
|
33
|
+
exec([gqlPath, ...gqlArgs].join(' '), { maxBuffer }, (err, stdout, stderr) => {
|
|
32
34
|
if (err !== null) {
|
|
33
35
|
reject(err);
|
|
34
36
|
}
|