@effect-gql/core 1.4.3 → 1.4.5
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/builder/index.cjs +233 -41
- package/builder/index.cjs.map +1 -1
- package/builder/index.js +232 -40
- package/builder/index.js.map +1 -1
- package/index.cjs +234 -42
- package/index.cjs.map +1 -1
- package/index.js +233 -41
- package/index.js.map +1 -1
- package/package.json +1 -1
package/builder/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GraphQLDirective, GraphQLEnumType, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLObjectType, GraphQLUnionType, GraphQLSchema, GraphQLNonNull, GraphQLString, GraphQLFloat, GraphQLBoolean, GraphQLInt, GraphQLList, parse, GraphQLError, validate, execute as execute$1 } from 'graphql';
|
|
2
2
|
export { DirectiveLocation } from 'graphql';
|
|
3
3
|
import { Pipeable, Context, Runtime, Effect, Queue, Option, Stream, Fiber, Ref } from 'effect';
|
|
4
|
-
import * as
|
|
4
|
+
import * as S2 from 'effect/Schema';
|
|
5
5
|
import * as AST from 'effect/SchemaAST';
|
|
6
6
|
|
|
7
7
|
// src/builder/index.ts
|
|
@@ -56,7 +56,7 @@ var toGraphQLType = (schema) => {
|
|
|
56
56
|
if (isIntegerType(ast)) {
|
|
57
57
|
return GraphQLInt;
|
|
58
58
|
}
|
|
59
|
-
return toGraphQLType(
|
|
59
|
+
return toGraphQLType(S2.make(ast.from));
|
|
60
60
|
}
|
|
61
61
|
if (ast._tag === "Literal") {
|
|
62
62
|
if (typeof ast.literal === "string") return GraphQLString;
|
|
@@ -68,7 +68,7 @@ var toGraphQLType = (schema) => {
|
|
|
68
68
|
if (ast._tag === "TupleType") {
|
|
69
69
|
const elements = ast.elements;
|
|
70
70
|
if (elements.length > 0) {
|
|
71
|
-
const elementSchema =
|
|
71
|
+
const elementSchema = S2.make(elements[0].type);
|
|
72
72
|
return new GraphQLList(toGraphQLType(elementSchema));
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -77,7 +77,7 @@ var toGraphQLType = (schema) => {
|
|
|
77
77
|
for (const field2 of ast.propertySignatures) {
|
|
78
78
|
const fieldName = String(field2.name);
|
|
79
79
|
if (fieldName === "_tag") continue;
|
|
80
|
-
const fieldSchema =
|
|
80
|
+
const fieldSchema = S2.make(field2.type);
|
|
81
81
|
let fieldType = toGraphQLType(fieldSchema);
|
|
82
82
|
if (!field2.isOptional) {
|
|
83
83
|
fieldType = new GraphQLNonNull(fieldType);
|
|
@@ -94,32 +94,32 @@ var toGraphQLType = (schema) => {
|
|
|
94
94
|
if (isOptionTransformation(ast)) {
|
|
95
95
|
const innerType = getOptionInnerType(ast.to);
|
|
96
96
|
if (innerType) {
|
|
97
|
-
return toGraphQLType(
|
|
97
|
+
return toGraphQLType(S2.make(innerType));
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
return toGraphQLType(
|
|
100
|
+
return toGraphQLType(S2.make(ast.to));
|
|
101
101
|
}
|
|
102
102
|
if (ast._tag === "Declaration") {
|
|
103
103
|
if (isOptionDeclaration(ast)) {
|
|
104
104
|
const innerType = getOptionInnerType(ast);
|
|
105
105
|
if (innerType) {
|
|
106
|
-
return toGraphQLType(
|
|
106
|
+
return toGraphQLType(S2.make(innerType));
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
const typeParams = ast.typeParameters;
|
|
110
110
|
if (typeParams && typeParams.length > 0) {
|
|
111
|
-
return toGraphQLType(
|
|
111
|
+
return toGraphQLType(S2.make(typeParams[0]));
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
if (ast._tag === "Union") {
|
|
115
115
|
const types = ast.types;
|
|
116
116
|
if (types.length > 0) {
|
|
117
|
-
return toGraphQLType(
|
|
117
|
+
return toGraphQLType(S2.make(types[0]));
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
if (ast._tag === "Suspend") {
|
|
121
121
|
const innerAst = ast.f();
|
|
122
|
-
return toGraphQLType(
|
|
122
|
+
return toGraphQLType(S2.make(innerAst));
|
|
123
123
|
}
|
|
124
124
|
return GraphQLString;
|
|
125
125
|
};
|
|
@@ -132,7 +132,7 @@ var toGraphQLInputType = (schema) => {
|
|
|
132
132
|
if (isIntegerType(ast)) {
|
|
133
133
|
return GraphQLInt;
|
|
134
134
|
}
|
|
135
|
-
return toGraphQLInputType(
|
|
135
|
+
return toGraphQLInputType(S2.make(ast.from));
|
|
136
136
|
}
|
|
137
137
|
if (ast._tag === "Literal") {
|
|
138
138
|
if (typeof ast.literal === "string") return GraphQLString;
|
|
@@ -144,7 +144,7 @@ var toGraphQLInputType = (schema) => {
|
|
|
144
144
|
if (ast._tag === "TupleType") {
|
|
145
145
|
const elements = ast.elements;
|
|
146
146
|
if (elements.length > 0) {
|
|
147
|
-
const elementSchema =
|
|
147
|
+
const elementSchema = S2.make(elements[0].type);
|
|
148
148
|
return new GraphQLList(toGraphQLInputType(elementSchema));
|
|
149
149
|
}
|
|
150
150
|
}
|
|
@@ -153,7 +153,7 @@ var toGraphQLInputType = (schema) => {
|
|
|
153
153
|
for (const field2 of ast.propertySignatures) {
|
|
154
154
|
const fieldName = String(field2.name);
|
|
155
155
|
if (fieldName === "_tag") continue;
|
|
156
|
-
const fieldSchema =
|
|
156
|
+
const fieldSchema = S2.make(field2.type);
|
|
157
157
|
let fieldType = toGraphQLInputType(fieldSchema);
|
|
158
158
|
if (!field2.isOptional) {
|
|
159
159
|
fieldType = new GraphQLNonNull(fieldType);
|
|
@@ -167,33 +167,33 @@ var toGraphQLInputType = (schema) => {
|
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
if (ast._tag === "Transformation") {
|
|
170
|
-
return toGraphQLInputType(
|
|
170
|
+
return toGraphQLInputType(S2.make(ast.from));
|
|
171
171
|
}
|
|
172
172
|
if (ast._tag === "Declaration") {
|
|
173
173
|
if (isOptionDeclaration(ast)) {
|
|
174
174
|
const innerType = getOptionInnerType(ast);
|
|
175
175
|
if (innerType) {
|
|
176
|
-
return toGraphQLInputType(
|
|
176
|
+
return toGraphQLInputType(S2.make(innerType));
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
const typeParams = ast.typeParameters;
|
|
180
180
|
if (typeParams && typeParams.length > 0) {
|
|
181
|
-
return toGraphQLInputType(
|
|
181
|
+
return toGraphQLInputType(S2.make(typeParams[0]));
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
if (ast._tag === "Union") {
|
|
185
185
|
const types = ast.types;
|
|
186
186
|
const nonNullTypes = types.filter((t) => t._tag !== "Literal" || t.literal !== null).filter((t) => t._tag !== "UndefinedKeyword");
|
|
187
187
|
if (nonNullTypes.length > 0) {
|
|
188
|
-
return toGraphQLInputType(
|
|
188
|
+
return toGraphQLInputType(S2.make(nonNullTypes[0]));
|
|
189
189
|
}
|
|
190
190
|
if (types.length > 0) {
|
|
191
|
-
return toGraphQLInputType(
|
|
191
|
+
return toGraphQLInputType(S2.make(types[0]));
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
if (ast._tag === "Suspend") {
|
|
195
195
|
const innerAst = ast.f();
|
|
196
|
-
return toGraphQLInputType(
|
|
196
|
+
return toGraphQLInputType(S2.make(innerAst));
|
|
197
197
|
}
|
|
198
198
|
return GraphQLString;
|
|
199
199
|
};
|
|
@@ -204,7 +204,7 @@ var toGraphQLArgs = (schema) => {
|
|
|
204
204
|
for (const field2 of ast.propertySignatures) {
|
|
205
205
|
const fieldName = String(field2.name);
|
|
206
206
|
if (fieldName === "_tag") continue;
|
|
207
|
-
const fieldSchema =
|
|
207
|
+
const fieldSchema = S2.make(field2.type);
|
|
208
208
|
let fieldType = toGraphQLInputType(fieldSchema);
|
|
209
209
|
if (!field2.isOptional) {
|
|
210
210
|
fieldType = new GraphQLNonNull(fieldType);
|
|
@@ -332,17 +332,17 @@ function toGraphQLTypeWithRegistry(schema, ctx) {
|
|
|
332
332
|
if (isOptionDeclaration2(ast)) {
|
|
333
333
|
const innerType = getOptionInnerType2(ast);
|
|
334
334
|
if (innerType) {
|
|
335
|
-
return toGraphQLTypeWithRegistry(
|
|
335
|
+
return toGraphQLTypeWithRegistry(S2.make(innerType), ctx);
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
338
|
const typeParams = ast.typeParameters;
|
|
339
339
|
if (typeParams && typeParams.length > 0) {
|
|
340
|
-
return toGraphQLTypeWithRegistry(
|
|
340
|
+
return toGraphQLTypeWithRegistry(S2.make(typeParams[0]), ctx);
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
343
|
if (ast._tag === "Suspend") {
|
|
344
344
|
const innerAst = ast.f();
|
|
345
|
-
return toGraphQLTypeWithRegistry(
|
|
345
|
+
return toGraphQLTypeWithRegistry(S2.make(innerAst), ctx);
|
|
346
346
|
}
|
|
347
347
|
return toGraphQLType(schema);
|
|
348
348
|
}
|
|
@@ -395,6 +395,12 @@ function handleTransformationAST(ast, ctx) {
|
|
|
395
395
|
const result = ctx.typeRegistry.get(typeName);
|
|
396
396
|
if (result) return result;
|
|
397
397
|
}
|
|
398
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
399
|
+
if (typeReg.schema.ast === memberAst) {
|
|
400
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
401
|
+
if (result) return result;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
398
404
|
if (memberAst._tag === "Transformation") {
|
|
399
405
|
const innerToAst = memberAst.to;
|
|
400
406
|
const transformedTypeName = ctx.astToTypeName?.get(innerToAst);
|
|
@@ -402,26 +408,61 @@ function handleTransformationAST(ast, ctx) {
|
|
|
402
408
|
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
403
409
|
if (result) return result;
|
|
404
410
|
}
|
|
411
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
412
|
+
if (typeReg.schema.ast === innerToAst) {
|
|
413
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
414
|
+
if (result) return result;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
419
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
420
|
+
(p) => String(p.name) === "value"
|
|
421
|
+
);
|
|
422
|
+
if (valueField) {
|
|
423
|
+
const valueType = valueField.type;
|
|
424
|
+
const valueTypeName = ctx.astToTypeName?.get(valueType);
|
|
425
|
+
if (valueTypeName) {
|
|
426
|
+
const result = ctx.typeRegistry.get(valueTypeName);
|
|
427
|
+
if (result) return result;
|
|
428
|
+
}
|
|
429
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
430
|
+
if (typeReg.schema.ast === valueType) {
|
|
431
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
432
|
+
if (result) return result;
|
|
433
|
+
}
|
|
434
|
+
let regAst = typeReg.schema.ast;
|
|
435
|
+
while (regAst._tag === "Transformation") {
|
|
436
|
+
regAst = regAst.to;
|
|
437
|
+
if (regAst === valueType) {
|
|
438
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
439
|
+
if (result) return result;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
const innerResult = toGraphQLTypeWithRegistry(S2.make(valueType), ctx);
|
|
444
|
+
if (innerResult) return innerResult;
|
|
445
|
+
}
|
|
405
446
|
}
|
|
406
447
|
}
|
|
407
448
|
}
|
|
408
449
|
const innerType = getOptionInnerType2(toAst);
|
|
409
450
|
if (innerType) {
|
|
410
|
-
return toGraphQLTypeWithRegistry(
|
|
451
|
+
return toGraphQLTypeWithRegistry(S2.make(innerType), ctx);
|
|
411
452
|
}
|
|
412
453
|
}
|
|
413
454
|
if (toAst._tag === "TupleType") {
|
|
414
455
|
if (toAst.rest && toAst.rest.length > 0) {
|
|
415
|
-
const elementSchema =
|
|
456
|
+
const elementSchema = S2.make(toAst.rest[0].type);
|
|
416
457
|
const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
|
|
417
458
|
return new GraphQLList(elementType);
|
|
418
459
|
} else if (toAst.elements.length > 0) {
|
|
419
|
-
const elementSchema =
|
|
460
|
+
const elementSchema = S2.make(toAst.elements[0].type);
|
|
420
461
|
const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
|
|
421
462
|
return new GraphQLList(elementType);
|
|
422
463
|
}
|
|
423
464
|
}
|
|
424
|
-
return toGraphQLTypeWithRegistry(
|
|
465
|
+
return toGraphQLTypeWithRegistry(S2.make(ast.to), ctx);
|
|
425
466
|
}
|
|
426
467
|
function handleUnionAST(ast, ctx) {
|
|
427
468
|
const allLiterals = ast.types.every((t) => t._tag === "Literal");
|
|
@@ -438,6 +479,12 @@ function handleUnionAST(ast, ctx) {
|
|
|
438
479
|
const result = ctx.typeRegistry.get(typeName);
|
|
439
480
|
if (result) return result;
|
|
440
481
|
}
|
|
482
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
483
|
+
if (typeReg.schema.ast === memberAst) {
|
|
484
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
485
|
+
if (result) return result;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
441
488
|
if (memberAst._tag === "Transformation") {
|
|
442
489
|
const toAst = memberAst.to;
|
|
443
490
|
const transformedTypeName = ctx.astToTypeName?.get(toAst);
|
|
@@ -445,12 +492,49 @@ function handleUnionAST(ast, ctx) {
|
|
|
445
492
|
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
446
493
|
if (result) return result;
|
|
447
494
|
}
|
|
495
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
496
|
+
if (typeReg.schema.ast === toAst) {
|
|
497
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
498
|
+
if (result) return result;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
503
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
504
|
+
(p) => String(p.name) === "value"
|
|
505
|
+
);
|
|
506
|
+
if (valueField) {
|
|
507
|
+
const valueType = valueField.type;
|
|
508
|
+
const valueTypeName = ctx.astToTypeName?.get(valueType);
|
|
509
|
+
if (valueTypeName) {
|
|
510
|
+
const result = ctx.typeRegistry.get(valueTypeName);
|
|
511
|
+
if (result) return result;
|
|
512
|
+
}
|
|
513
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
514
|
+
if (typeReg.schema.ast === valueType) {
|
|
515
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
516
|
+
if (result) return result;
|
|
517
|
+
}
|
|
518
|
+
let regAst = typeReg.schema.ast;
|
|
519
|
+
while (regAst._tag === "Transformation") {
|
|
520
|
+
regAst = regAst.to;
|
|
521
|
+
if (regAst === valueType) {
|
|
522
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
523
|
+
if (result) return result;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
const innerResult = toGraphQLTypeWithRegistry(S2.make(valueType), ctx);
|
|
528
|
+
if (innerResult) {
|
|
529
|
+
return innerResult;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
448
532
|
}
|
|
449
533
|
}
|
|
450
534
|
if (ast.types.length > 0) {
|
|
451
|
-
return toGraphQLTypeWithRegistry(
|
|
535
|
+
return toGraphQLTypeWithRegistry(S2.make(ast.types[0]), ctx);
|
|
452
536
|
}
|
|
453
|
-
return toGraphQLType(
|
|
537
|
+
return toGraphQLType(S2.make(ast));
|
|
454
538
|
}
|
|
455
539
|
function findEnumForLiteralUnion(types, ctx) {
|
|
456
540
|
const literalValues = types.map((t) => String(t.literal)).sort();
|
|
@@ -493,15 +577,15 @@ function findEnumForLiteral(ast, ctx) {
|
|
|
493
577
|
}
|
|
494
578
|
function handleTupleTypeAST(ast, ctx) {
|
|
495
579
|
if (ast.rest && ast.rest.length > 0) {
|
|
496
|
-
const elementSchema =
|
|
580
|
+
const elementSchema = S2.make(ast.rest[0].type);
|
|
497
581
|
const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
|
|
498
582
|
return new GraphQLList(elementType);
|
|
499
583
|
} else if (ast.elements && ast.elements.length > 0) {
|
|
500
|
-
const elementSchema =
|
|
584
|
+
const elementSchema = S2.make(ast.elements[0].type);
|
|
501
585
|
const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
|
|
502
586
|
return new GraphQLList(elementType);
|
|
503
587
|
}
|
|
504
|
-
return toGraphQLType(
|
|
588
|
+
return toGraphQLType(S2.make(ast));
|
|
505
589
|
}
|
|
506
590
|
function schemaToFields(schema, ctx) {
|
|
507
591
|
let ast = schema.ast;
|
|
@@ -525,7 +609,7 @@ function schemaToFields(schema, ctx) {
|
|
|
525
609
|
for (const field2 of ast.propertySignatures) {
|
|
526
610
|
const fieldName = String(field2.name);
|
|
527
611
|
if (fieldName === "_tag") continue;
|
|
528
|
-
const fieldSchema =
|
|
612
|
+
const fieldSchema = S2.make(field2.type);
|
|
529
613
|
let fieldType = toGraphQLTypeWithRegistry(fieldSchema, ctx);
|
|
530
614
|
if (!field2.isOptional) {
|
|
531
615
|
fieldType = getNonNull(fieldType);
|
|
@@ -546,7 +630,7 @@ function schemaToInputFields(schema, enumRegistry, inputRegistry, inputs, enums,
|
|
|
546
630
|
for (const field2 of ast.propertySignatures) {
|
|
547
631
|
const fieldName = String(field2.name);
|
|
548
632
|
if (fieldName === "_tag") continue;
|
|
549
|
-
const fieldSchema =
|
|
633
|
+
const fieldSchema = S2.make(field2.type);
|
|
550
634
|
let fieldType = toGraphQLInputTypeWithRegistry(
|
|
551
635
|
fieldSchema,
|
|
552
636
|
enumRegistry,
|
|
@@ -619,6 +703,12 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
619
703
|
const result = inputRegistry.get(inputName);
|
|
620
704
|
if (result) return result;
|
|
621
705
|
}
|
|
706
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
707
|
+
if (inputReg.schema.ast === memberAst) {
|
|
708
|
+
const result = inputRegistry.get(regInputName);
|
|
709
|
+
if (result) return result;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
622
712
|
if (memberAst._tag === "Transformation") {
|
|
623
713
|
const innerToAst = memberAst.to;
|
|
624
714
|
const transformedInputName = cache?.astToInputName?.get(innerToAst);
|
|
@@ -626,11 +716,59 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
626
716
|
const result = inputRegistry.get(transformedInputName);
|
|
627
717
|
if (result) return result;
|
|
628
718
|
}
|
|
719
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
720
|
+
if (inputReg.schema.ast === innerToAst) {
|
|
721
|
+
const result = inputRegistry.get(regInputName);
|
|
722
|
+
if (result) return result;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
727
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
728
|
+
(p) => String(p.name) === "value"
|
|
729
|
+
);
|
|
730
|
+
if (valueField) {
|
|
731
|
+
const valueType = valueField.type;
|
|
732
|
+
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
733
|
+
if (valueInputName) {
|
|
734
|
+
const result = inputRegistry.get(valueInputName);
|
|
735
|
+
if (result) return result;
|
|
736
|
+
}
|
|
737
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
738
|
+
if (inputReg.schema.ast === valueType) {
|
|
739
|
+
const result = inputRegistry.get(regInputName);
|
|
740
|
+
if (result) return result;
|
|
741
|
+
}
|
|
742
|
+
let regAst = inputReg.schema.ast;
|
|
743
|
+
while (regAst._tag === "Transformation") {
|
|
744
|
+
regAst = regAst.to;
|
|
745
|
+
if (regAst === valueType) {
|
|
746
|
+
const result = inputRegistry.get(regInputName);
|
|
747
|
+
if (result) return result;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
751
|
+
const result = inputRegistry.get(regInputName);
|
|
752
|
+
if (result) return result;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
756
|
+
S2.make(valueType),
|
|
757
|
+
enumRegistry,
|
|
758
|
+
inputRegistry,
|
|
759
|
+
inputs,
|
|
760
|
+
enums,
|
|
761
|
+
cache
|
|
762
|
+
);
|
|
763
|
+
if (innerResult) {
|
|
764
|
+
return innerResult;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
629
767
|
}
|
|
630
768
|
}
|
|
631
769
|
}
|
|
632
770
|
return toGraphQLInputTypeWithRegistry(
|
|
633
|
-
|
|
771
|
+
S2.make(toAst),
|
|
634
772
|
enumRegistry,
|
|
635
773
|
inputRegistry,
|
|
636
774
|
inputs,
|
|
@@ -643,7 +781,7 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
643
781
|
const nonUndefinedTypes = unionAst.types.filter((t) => t._tag !== "UndefinedKeyword");
|
|
644
782
|
if (nonUndefinedTypes.length === 1 && nonUndefinedTypes[0]._tag === "Union") {
|
|
645
783
|
return toGraphQLInputTypeWithRegistry(
|
|
646
|
-
|
|
784
|
+
S2.make(nonUndefinedTypes[0]),
|
|
647
785
|
enumRegistry,
|
|
648
786
|
inputRegistry,
|
|
649
787
|
inputs,
|
|
@@ -653,7 +791,7 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
653
791
|
}
|
|
654
792
|
if (nonUndefinedTypes.length === 1 && nonUndefinedTypes[0]._tag === "TypeLiteral") {
|
|
655
793
|
return toGraphQLInputTypeWithRegistry(
|
|
656
|
-
|
|
794
|
+
S2.make(nonUndefinedTypes[0]),
|
|
657
795
|
enumRegistry,
|
|
658
796
|
inputRegistry,
|
|
659
797
|
inputs,
|
|
@@ -667,6 +805,12 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
667
805
|
const result = inputRegistry.get(inputName);
|
|
668
806
|
if (result) return result;
|
|
669
807
|
}
|
|
808
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
809
|
+
if (inputReg.schema.ast === memberAst) {
|
|
810
|
+
const result = inputRegistry.get(regInputName);
|
|
811
|
+
if (result) return result;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
670
814
|
if (memberAst._tag === "Transformation") {
|
|
671
815
|
const toAst = memberAst.to;
|
|
672
816
|
const transformedInputName = cache?.astToInputName?.get(toAst);
|
|
@@ -674,6 +818,54 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
674
818
|
const result = inputRegistry.get(transformedInputName);
|
|
675
819
|
if (result) return result;
|
|
676
820
|
}
|
|
821
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
822
|
+
if (inputReg.schema.ast === toAst) {
|
|
823
|
+
const result = inputRegistry.get(regInputName);
|
|
824
|
+
if (result) return result;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
829
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
830
|
+
(p) => String(p.name) === "value"
|
|
831
|
+
);
|
|
832
|
+
if (valueField) {
|
|
833
|
+
const valueType = valueField.type;
|
|
834
|
+
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
835
|
+
if (valueInputName) {
|
|
836
|
+
const result = inputRegistry.get(valueInputName);
|
|
837
|
+
if (result) return result;
|
|
838
|
+
}
|
|
839
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
840
|
+
if (inputReg.schema.ast === valueType) {
|
|
841
|
+
const result = inputRegistry.get(regInputName);
|
|
842
|
+
if (result) return result;
|
|
843
|
+
}
|
|
844
|
+
let regAst = inputReg.schema.ast;
|
|
845
|
+
while (regAst._tag === "Transformation") {
|
|
846
|
+
regAst = regAst.to;
|
|
847
|
+
if (regAst === valueType) {
|
|
848
|
+
const result = inputRegistry.get(regInputName);
|
|
849
|
+
if (result) return result;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
853
|
+
const result = inputRegistry.get(regInputName);
|
|
854
|
+
if (result) return result;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
858
|
+
S2.make(valueType),
|
|
859
|
+
enumRegistry,
|
|
860
|
+
inputRegistry,
|
|
861
|
+
inputs,
|
|
862
|
+
enums,
|
|
863
|
+
cache
|
|
864
|
+
);
|
|
865
|
+
if (innerResult) {
|
|
866
|
+
return innerResult;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
677
869
|
}
|
|
678
870
|
}
|
|
679
871
|
const allLiterals = unionAst.types.every((t) => t._tag === "Literal");
|
|
@@ -708,7 +900,7 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
708
900
|
if (ast._tag === "Suspend") {
|
|
709
901
|
const innerAst = ast.f();
|
|
710
902
|
return toGraphQLInputTypeWithRegistry(
|
|
711
|
-
|
|
903
|
+
S2.make(innerAst),
|
|
712
904
|
enumRegistry,
|
|
713
905
|
inputRegistry,
|
|
714
906
|
inputs,
|
|
@@ -725,7 +917,7 @@ function toGraphQLArgsWithRegistry(schema, enumRegistry, inputRegistry, inputs,
|
|
|
725
917
|
for (const field2 of ast.propertySignatures) {
|
|
726
918
|
const fieldName = String(field2.name);
|
|
727
919
|
if (fieldName === "_tag") continue;
|
|
728
|
-
const fieldSchema =
|
|
920
|
+
const fieldSchema = S2.make(field2.type);
|
|
729
921
|
let fieldType = toGraphQLInputTypeWithRegistry(
|
|
730
922
|
fieldSchema,
|
|
731
923
|
enumRegistry,
|
|
@@ -762,7 +954,7 @@ function isOptionSchema(schema) {
|
|
|
762
954
|
}
|
|
763
955
|
function encodeResolverOutput(schema, value) {
|
|
764
956
|
if (isOptionSchema(schema)) {
|
|
765
|
-
return Effect.orDie(
|
|
957
|
+
return Effect.orDie(S2.encode(schema)(value));
|
|
766
958
|
}
|
|
767
959
|
return Effect.succeed(value);
|
|
768
960
|
}
|