@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.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var graphql = require('graphql');
|
|
4
4
|
var effect = require('effect');
|
|
5
|
-
var
|
|
5
|
+
var S2 = require('effect/Schema');
|
|
6
6
|
var AST = require('effect/SchemaAST');
|
|
7
7
|
|
|
8
8
|
function _interopNamespace(e) {
|
|
@@ -23,7 +23,7 @@ function _interopNamespace(e) {
|
|
|
23
23
|
return Object.freeze(n);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var S2__namespace = /*#__PURE__*/_interopNamespace(S2);
|
|
27
27
|
var AST__namespace = /*#__PURE__*/_interopNamespace(AST);
|
|
28
28
|
|
|
29
29
|
// src/builder/index.ts
|
|
@@ -78,7 +78,7 @@ var toGraphQLType = (schema) => {
|
|
|
78
78
|
if (isIntegerType(ast)) {
|
|
79
79
|
return graphql.GraphQLInt;
|
|
80
80
|
}
|
|
81
|
-
return toGraphQLType(
|
|
81
|
+
return toGraphQLType(S2__namespace.make(ast.from));
|
|
82
82
|
}
|
|
83
83
|
if (ast._tag === "Literal") {
|
|
84
84
|
if (typeof ast.literal === "string") return graphql.GraphQLString;
|
|
@@ -90,7 +90,7 @@ var toGraphQLType = (schema) => {
|
|
|
90
90
|
if (ast._tag === "TupleType") {
|
|
91
91
|
const elements = ast.elements;
|
|
92
92
|
if (elements.length > 0) {
|
|
93
|
-
const elementSchema =
|
|
93
|
+
const elementSchema = S2__namespace.make(elements[0].type);
|
|
94
94
|
return new graphql.GraphQLList(toGraphQLType(elementSchema));
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -99,7 +99,7 @@ var toGraphQLType = (schema) => {
|
|
|
99
99
|
for (const field2 of ast.propertySignatures) {
|
|
100
100
|
const fieldName = String(field2.name);
|
|
101
101
|
if (fieldName === "_tag") continue;
|
|
102
|
-
const fieldSchema =
|
|
102
|
+
const fieldSchema = S2__namespace.make(field2.type);
|
|
103
103
|
let fieldType = toGraphQLType(fieldSchema);
|
|
104
104
|
if (!field2.isOptional) {
|
|
105
105
|
fieldType = new graphql.GraphQLNonNull(fieldType);
|
|
@@ -116,32 +116,32 @@ var toGraphQLType = (schema) => {
|
|
|
116
116
|
if (isOptionTransformation(ast)) {
|
|
117
117
|
const innerType = getOptionInnerType(ast.to);
|
|
118
118
|
if (innerType) {
|
|
119
|
-
return toGraphQLType(
|
|
119
|
+
return toGraphQLType(S2__namespace.make(innerType));
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
return toGraphQLType(
|
|
122
|
+
return toGraphQLType(S2__namespace.make(ast.to));
|
|
123
123
|
}
|
|
124
124
|
if (ast._tag === "Declaration") {
|
|
125
125
|
if (isOptionDeclaration(ast)) {
|
|
126
126
|
const innerType = getOptionInnerType(ast);
|
|
127
127
|
if (innerType) {
|
|
128
|
-
return toGraphQLType(
|
|
128
|
+
return toGraphQLType(S2__namespace.make(innerType));
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
const typeParams = ast.typeParameters;
|
|
132
132
|
if (typeParams && typeParams.length > 0) {
|
|
133
|
-
return toGraphQLType(
|
|
133
|
+
return toGraphQLType(S2__namespace.make(typeParams[0]));
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
if (ast._tag === "Union") {
|
|
137
137
|
const types = ast.types;
|
|
138
138
|
if (types.length > 0) {
|
|
139
|
-
return toGraphQLType(
|
|
139
|
+
return toGraphQLType(S2__namespace.make(types[0]));
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
if (ast._tag === "Suspend") {
|
|
143
143
|
const innerAst = ast.f();
|
|
144
|
-
return toGraphQLType(
|
|
144
|
+
return toGraphQLType(S2__namespace.make(innerAst));
|
|
145
145
|
}
|
|
146
146
|
return graphql.GraphQLString;
|
|
147
147
|
};
|
|
@@ -154,7 +154,7 @@ var toGraphQLInputType = (schema) => {
|
|
|
154
154
|
if (isIntegerType(ast)) {
|
|
155
155
|
return graphql.GraphQLInt;
|
|
156
156
|
}
|
|
157
|
-
return toGraphQLInputType(
|
|
157
|
+
return toGraphQLInputType(S2__namespace.make(ast.from));
|
|
158
158
|
}
|
|
159
159
|
if (ast._tag === "Literal") {
|
|
160
160
|
if (typeof ast.literal === "string") return graphql.GraphQLString;
|
|
@@ -166,7 +166,7 @@ var toGraphQLInputType = (schema) => {
|
|
|
166
166
|
if (ast._tag === "TupleType") {
|
|
167
167
|
const elements = ast.elements;
|
|
168
168
|
if (elements.length > 0) {
|
|
169
|
-
const elementSchema =
|
|
169
|
+
const elementSchema = S2__namespace.make(elements[0].type);
|
|
170
170
|
return new graphql.GraphQLList(toGraphQLInputType(elementSchema));
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -175,7 +175,7 @@ var toGraphQLInputType = (schema) => {
|
|
|
175
175
|
for (const field2 of ast.propertySignatures) {
|
|
176
176
|
const fieldName = String(field2.name);
|
|
177
177
|
if (fieldName === "_tag") continue;
|
|
178
|
-
const fieldSchema =
|
|
178
|
+
const fieldSchema = S2__namespace.make(field2.type);
|
|
179
179
|
let fieldType = toGraphQLInputType(fieldSchema);
|
|
180
180
|
if (!field2.isOptional) {
|
|
181
181
|
fieldType = new graphql.GraphQLNonNull(fieldType);
|
|
@@ -189,33 +189,33 @@ var toGraphQLInputType = (schema) => {
|
|
|
189
189
|
});
|
|
190
190
|
}
|
|
191
191
|
if (ast._tag === "Transformation") {
|
|
192
|
-
return toGraphQLInputType(
|
|
192
|
+
return toGraphQLInputType(S2__namespace.make(ast.from));
|
|
193
193
|
}
|
|
194
194
|
if (ast._tag === "Declaration") {
|
|
195
195
|
if (isOptionDeclaration(ast)) {
|
|
196
196
|
const innerType = getOptionInnerType(ast);
|
|
197
197
|
if (innerType) {
|
|
198
|
-
return toGraphQLInputType(
|
|
198
|
+
return toGraphQLInputType(S2__namespace.make(innerType));
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
const typeParams = ast.typeParameters;
|
|
202
202
|
if (typeParams && typeParams.length > 0) {
|
|
203
|
-
return toGraphQLInputType(
|
|
203
|
+
return toGraphQLInputType(S2__namespace.make(typeParams[0]));
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
if (ast._tag === "Union") {
|
|
207
207
|
const types = ast.types;
|
|
208
208
|
const nonNullTypes = types.filter((t) => t._tag !== "Literal" || t.literal !== null).filter((t) => t._tag !== "UndefinedKeyword");
|
|
209
209
|
if (nonNullTypes.length > 0) {
|
|
210
|
-
return toGraphQLInputType(
|
|
210
|
+
return toGraphQLInputType(S2__namespace.make(nonNullTypes[0]));
|
|
211
211
|
}
|
|
212
212
|
if (types.length > 0) {
|
|
213
|
-
return toGraphQLInputType(
|
|
213
|
+
return toGraphQLInputType(S2__namespace.make(types[0]));
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
if (ast._tag === "Suspend") {
|
|
217
217
|
const innerAst = ast.f();
|
|
218
|
-
return toGraphQLInputType(
|
|
218
|
+
return toGraphQLInputType(S2__namespace.make(innerAst));
|
|
219
219
|
}
|
|
220
220
|
return graphql.GraphQLString;
|
|
221
221
|
};
|
|
@@ -226,7 +226,7 @@ var toGraphQLArgs = (schema) => {
|
|
|
226
226
|
for (const field2 of ast.propertySignatures) {
|
|
227
227
|
const fieldName = String(field2.name);
|
|
228
228
|
if (fieldName === "_tag") continue;
|
|
229
|
-
const fieldSchema =
|
|
229
|
+
const fieldSchema = S2__namespace.make(field2.type);
|
|
230
230
|
let fieldType = toGraphQLInputType(fieldSchema);
|
|
231
231
|
if (!field2.isOptional) {
|
|
232
232
|
fieldType = new graphql.GraphQLNonNull(fieldType);
|
|
@@ -354,17 +354,17 @@ function toGraphQLTypeWithRegistry(schema, ctx) {
|
|
|
354
354
|
if (isOptionDeclaration2(ast)) {
|
|
355
355
|
const innerType = getOptionInnerType2(ast);
|
|
356
356
|
if (innerType) {
|
|
357
|
-
return toGraphQLTypeWithRegistry(
|
|
357
|
+
return toGraphQLTypeWithRegistry(S2__namespace.make(innerType), ctx);
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
const typeParams = ast.typeParameters;
|
|
361
361
|
if (typeParams && typeParams.length > 0) {
|
|
362
|
-
return toGraphQLTypeWithRegistry(
|
|
362
|
+
return toGraphQLTypeWithRegistry(S2__namespace.make(typeParams[0]), ctx);
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
365
|
if (ast._tag === "Suspend") {
|
|
366
366
|
const innerAst = ast.f();
|
|
367
|
-
return toGraphQLTypeWithRegistry(
|
|
367
|
+
return toGraphQLTypeWithRegistry(S2__namespace.make(innerAst), ctx);
|
|
368
368
|
}
|
|
369
369
|
return toGraphQLType(schema);
|
|
370
370
|
}
|
|
@@ -417,6 +417,12 @@ function handleTransformationAST(ast, ctx) {
|
|
|
417
417
|
const result = ctx.typeRegistry.get(typeName);
|
|
418
418
|
if (result) return result;
|
|
419
419
|
}
|
|
420
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
421
|
+
if (typeReg.schema.ast === memberAst) {
|
|
422
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
423
|
+
if (result) return result;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
420
426
|
if (memberAst._tag === "Transformation") {
|
|
421
427
|
const innerToAst = memberAst.to;
|
|
422
428
|
const transformedTypeName = ctx.astToTypeName?.get(innerToAst);
|
|
@@ -424,26 +430,61 @@ function handleTransformationAST(ast, ctx) {
|
|
|
424
430
|
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
425
431
|
if (result) return result;
|
|
426
432
|
}
|
|
433
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
434
|
+
if (typeReg.schema.ast === innerToAst) {
|
|
435
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
436
|
+
if (result) return result;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
441
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
442
|
+
(p) => String(p.name) === "value"
|
|
443
|
+
);
|
|
444
|
+
if (valueField) {
|
|
445
|
+
const valueType = valueField.type;
|
|
446
|
+
const valueTypeName = ctx.astToTypeName?.get(valueType);
|
|
447
|
+
if (valueTypeName) {
|
|
448
|
+
const result = ctx.typeRegistry.get(valueTypeName);
|
|
449
|
+
if (result) return result;
|
|
450
|
+
}
|
|
451
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
452
|
+
if (typeReg.schema.ast === valueType) {
|
|
453
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
454
|
+
if (result) return result;
|
|
455
|
+
}
|
|
456
|
+
let regAst = typeReg.schema.ast;
|
|
457
|
+
while (regAst._tag === "Transformation") {
|
|
458
|
+
regAst = regAst.to;
|
|
459
|
+
if (regAst === valueType) {
|
|
460
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
461
|
+
if (result) return result;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
const innerResult = toGraphQLTypeWithRegistry(S2__namespace.make(valueType), ctx);
|
|
466
|
+
if (innerResult) return innerResult;
|
|
467
|
+
}
|
|
427
468
|
}
|
|
428
469
|
}
|
|
429
470
|
}
|
|
430
471
|
const innerType = getOptionInnerType2(toAst);
|
|
431
472
|
if (innerType) {
|
|
432
|
-
return toGraphQLTypeWithRegistry(
|
|
473
|
+
return toGraphQLTypeWithRegistry(S2__namespace.make(innerType), ctx);
|
|
433
474
|
}
|
|
434
475
|
}
|
|
435
476
|
if (toAst._tag === "TupleType") {
|
|
436
477
|
if (toAst.rest && toAst.rest.length > 0) {
|
|
437
|
-
const elementSchema =
|
|
478
|
+
const elementSchema = S2__namespace.make(toAst.rest[0].type);
|
|
438
479
|
const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
|
|
439
480
|
return new graphql.GraphQLList(elementType);
|
|
440
481
|
} else if (toAst.elements.length > 0) {
|
|
441
|
-
const elementSchema =
|
|
482
|
+
const elementSchema = S2__namespace.make(toAst.elements[0].type);
|
|
442
483
|
const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
|
|
443
484
|
return new graphql.GraphQLList(elementType);
|
|
444
485
|
}
|
|
445
486
|
}
|
|
446
|
-
return toGraphQLTypeWithRegistry(
|
|
487
|
+
return toGraphQLTypeWithRegistry(S2__namespace.make(ast.to), ctx);
|
|
447
488
|
}
|
|
448
489
|
function handleUnionAST(ast, ctx) {
|
|
449
490
|
const allLiterals = ast.types.every((t) => t._tag === "Literal");
|
|
@@ -460,6 +501,12 @@ function handleUnionAST(ast, ctx) {
|
|
|
460
501
|
const result = ctx.typeRegistry.get(typeName);
|
|
461
502
|
if (result) return result;
|
|
462
503
|
}
|
|
504
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
505
|
+
if (typeReg.schema.ast === memberAst) {
|
|
506
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
507
|
+
if (result) return result;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
463
510
|
if (memberAst._tag === "Transformation") {
|
|
464
511
|
const toAst = memberAst.to;
|
|
465
512
|
const transformedTypeName = ctx.astToTypeName?.get(toAst);
|
|
@@ -467,12 +514,49 @@ function handleUnionAST(ast, ctx) {
|
|
|
467
514
|
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
468
515
|
if (result) return result;
|
|
469
516
|
}
|
|
517
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
518
|
+
if (typeReg.schema.ast === toAst) {
|
|
519
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
520
|
+
if (result) return result;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
525
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
526
|
+
(p) => String(p.name) === "value"
|
|
527
|
+
);
|
|
528
|
+
if (valueField) {
|
|
529
|
+
const valueType = valueField.type;
|
|
530
|
+
const valueTypeName = ctx.astToTypeName?.get(valueType);
|
|
531
|
+
if (valueTypeName) {
|
|
532
|
+
const result = ctx.typeRegistry.get(valueTypeName);
|
|
533
|
+
if (result) return result;
|
|
534
|
+
}
|
|
535
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
536
|
+
if (typeReg.schema.ast === valueType) {
|
|
537
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
538
|
+
if (result) return result;
|
|
539
|
+
}
|
|
540
|
+
let regAst = typeReg.schema.ast;
|
|
541
|
+
while (regAst._tag === "Transformation") {
|
|
542
|
+
regAst = regAst.to;
|
|
543
|
+
if (regAst === valueType) {
|
|
544
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
545
|
+
if (result) return result;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
const innerResult = toGraphQLTypeWithRegistry(S2__namespace.make(valueType), ctx);
|
|
550
|
+
if (innerResult) {
|
|
551
|
+
return innerResult;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
470
554
|
}
|
|
471
555
|
}
|
|
472
556
|
if (ast.types.length > 0) {
|
|
473
|
-
return toGraphQLTypeWithRegistry(
|
|
557
|
+
return toGraphQLTypeWithRegistry(S2__namespace.make(ast.types[0]), ctx);
|
|
474
558
|
}
|
|
475
|
-
return toGraphQLType(
|
|
559
|
+
return toGraphQLType(S2__namespace.make(ast));
|
|
476
560
|
}
|
|
477
561
|
function findEnumForLiteralUnion(types, ctx) {
|
|
478
562
|
const literalValues = types.map((t) => String(t.literal)).sort();
|
|
@@ -515,15 +599,15 @@ function findEnumForLiteral(ast, ctx) {
|
|
|
515
599
|
}
|
|
516
600
|
function handleTupleTypeAST(ast, ctx) {
|
|
517
601
|
if (ast.rest && ast.rest.length > 0) {
|
|
518
|
-
const elementSchema =
|
|
602
|
+
const elementSchema = S2__namespace.make(ast.rest[0].type);
|
|
519
603
|
const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
|
|
520
604
|
return new graphql.GraphQLList(elementType);
|
|
521
605
|
} else if (ast.elements && ast.elements.length > 0) {
|
|
522
|
-
const elementSchema =
|
|
606
|
+
const elementSchema = S2__namespace.make(ast.elements[0].type);
|
|
523
607
|
const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
|
|
524
608
|
return new graphql.GraphQLList(elementType);
|
|
525
609
|
}
|
|
526
|
-
return toGraphQLType(
|
|
610
|
+
return toGraphQLType(S2__namespace.make(ast));
|
|
527
611
|
}
|
|
528
612
|
function schemaToFields(schema, ctx) {
|
|
529
613
|
let ast = schema.ast;
|
|
@@ -547,7 +631,7 @@ function schemaToFields(schema, ctx) {
|
|
|
547
631
|
for (const field2 of ast.propertySignatures) {
|
|
548
632
|
const fieldName = String(field2.name);
|
|
549
633
|
if (fieldName === "_tag") continue;
|
|
550
|
-
const fieldSchema =
|
|
634
|
+
const fieldSchema = S2__namespace.make(field2.type);
|
|
551
635
|
let fieldType = toGraphQLTypeWithRegistry(fieldSchema, ctx);
|
|
552
636
|
if (!field2.isOptional) {
|
|
553
637
|
fieldType = getNonNull(fieldType);
|
|
@@ -568,7 +652,7 @@ function schemaToInputFields(schema, enumRegistry, inputRegistry, inputs, enums,
|
|
|
568
652
|
for (const field2 of ast.propertySignatures) {
|
|
569
653
|
const fieldName = String(field2.name);
|
|
570
654
|
if (fieldName === "_tag") continue;
|
|
571
|
-
const fieldSchema =
|
|
655
|
+
const fieldSchema = S2__namespace.make(field2.type);
|
|
572
656
|
let fieldType = toGraphQLInputTypeWithRegistry(
|
|
573
657
|
fieldSchema,
|
|
574
658
|
enumRegistry,
|
|
@@ -641,6 +725,12 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
641
725
|
const result = inputRegistry.get(inputName);
|
|
642
726
|
if (result) return result;
|
|
643
727
|
}
|
|
728
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
729
|
+
if (inputReg.schema.ast === memberAst) {
|
|
730
|
+
const result = inputRegistry.get(regInputName);
|
|
731
|
+
if (result) return result;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
644
734
|
if (memberAst._tag === "Transformation") {
|
|
645
735
|
const innerToAst = memberAst.to;
|
|
646
736
|
const transformedInputName = cache?.astToInputName?.get(innerToAst);
|
|
@@ -648,11 +738,59 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
648
738
|
const result = inputRegistry.get(transformedInputName);
|
|
649
739
|
if (result) return result;
|
|
650
740
|
}
|
|
741
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
742
|
+
if (inputReg.schema.ast === innerToAst) {
|
|
743
|
+
const result = inputRegistry.get(regInputName);
|
|
744
|
+
if (result) return result;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
749
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
750
|
+
(p) => String(p.name) === "value"
|
|
751
|
+
);
|
|
752
|
+
if (valueField) {
|
|
753
|
+
const valueType = valueField.type;
|
|
754
|
+
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
755
|
+
if (valueInputName) {
|
|
756
|
+
const result = inputRegistry.get(valueInputName);
|
|
757
|
+
if (result) return result;
|
|
758
|
+
}
|
|
759
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
760
|
+
if (inputReg.schema.ast === valueType) {
|
|
761
|
+
const result = inputRegistry.get(regInputName);
|
|
762
|
+
if (result) return result;
|
|
763
|
+
}
|
|
764
|
+
let regAst = inputReg.schema.ast;
|
|
765
|
+
while (regAst._tag === "Transformation") {
|
|
766
|
+
regAst = regAst.to;
|
|
767
|
+
if (regAst === valueType) {
|
|
768
|
+
const result = inputRegistry.get(regInputName);
|
|
769
|
+
if (result) return result;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
773
|
+
const result = inputRegistry.get(regInputName);
|
|
774
|
+
if (result) return result;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
778
|
+
S2__namespace.make(valueType),
|
|
779
|
+
enumRegistry,
|
|
780
|
+
inputRegistry,
|
|
781
|
+
inputs,
|
|
782
|
+
enums,
|
|
783
|
+
cache
|
|
784
|
+
);
|
|
785
|
+
if (innerResult) {
|
|
786
|
+
return innerResult;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
651
789
|
}
|
|
652
790
|
}
|
|
653
791
|
}
|
|
654
792
|
return toGraphQLInputTypeWithRegistry(
|
|
655
|
-
|
|
793
|
+
S2__namespace.make(toAst),
|
|
656
794
|
enumRegistry,
|
|
657
795
|
inputRegistry,
|
|
658
796
|
inputs,
|
|
@@ -665,7 +803,7 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
665
803
|
const nonUndefinedTypes = unionAst.types.filter((t) => t._tag !== "UndefinedKeyword");
|
|
666
804
|
if (nonUndefinedTypes.length === 1 && nonUndefinedTypes[0]._tag === "Union") {
|
|
667
805
|
return toGraphQLInputTypeWithRegistry(
|
|
668
|
-
|
|
806
|
+
S2__namespace.make(nonUndefinedTypes[0]),
|
|
669
807
|
enumRegistry,
|
|
670
808
|
inputRegistry,
|
|
671
809
|
inputs,
|
|
@@ -675,7 +813,7 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
675
813
|
}
|
|
676
814
|
if (nonUndefinedTypes.length === 1 && nonUndefinedTypes[0]._tag === "TypeLiteral") {
|
|
677
815
|
return toGraphQLInputTypeWithRegistry(
|
|
678
|
-
|
|
816
|
+
S2__namespace.make(nonUndefinedTypes[0]),
|
|
679
817
|
enumRegistry,
|
|
680
818
|
inputRegistry,
|
|
681
819
|
inputs,
|
|
@@ -689,6 +827,12 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
689
827
|
const result = inputRegistry.get(inputName);
|
|
690
828
|
if (result) return result;
|
|
691
829
|
}
|
|
830
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
831
|
+
if (inputReg.schema.ast === memberAst) {
|
|
832
|
+
const result = inputRegistry.get(regInputName);
|
|
833
|
+
if (result) return result;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
692
836
|
if (memberAst._tag === "Transformation") {
|
|
693
837
|
const toAst = memberAst.to;
|
|
694
838
|
const transformedInputName = cache?.astToInputName?.get(toAst);
|
|
@@ -696,6 +840,54 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
696
840
|
const result = inputRegistry.get(transformedInputName);
|
|
697
841
|
if (result) return result;
|
|
698
842
|
}
|
|
843
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
844
|
+
if (inputReg.schema.ast === toAst) {
|
|
845
|
+
const result = inputRegistry.get(regInputName);
|
|
846
|
+
if (result) return result;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
851
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
852
|
+
(p) => String(p.name) === "value"
|
|
853
|
+
);
|
|
854
|
+
if (valueField) {
|
|
855
|
+
const valueType = valueField.type;
|
|
856
|
+
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
857
|
+
if (valueInputName) {
|
|
858
|
+
const result = inputRegistry.get(valueInputName);
|
|
859
|
+
if (result) return result;
|
|
860
|
+
}
|
|
861
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
862
|
+
if (inputReg.schema.ast === valueType) {
|
|
863
|
+
const result = inputRegistry.get(regInputName);
|
|
864
|
+
if (result) return result;
|
|
865
|
+
}
|
|
866
|
+
let regAst = inputReg.schema.ast;
|
|
867
|
+
while (regAst._tag === "Transformation") {
|
|
868
|
+
regAst = regAst.to;
|
|
869
|
+
if (regAst === valueType) {
|
|
870
|
+
const result = inputRegistry.get(regInputName);
|
|
871
|
+
if (result) return result;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
875
|
+
const result = inputRegistry.get(regInputName);
|
|
876
|
+
if (result) return result;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
880
|
+
S2__namespace.make(valueType),
|
|
881
|
+
enumRegistry,
|
|
882
|
+
inputRegistry,
|
|
883
|
+
inputs,
|
|
884
|
+
enums,
|
|
885
|
+
cache
|
|
886
|
+
);
|
|
887
|
+
if (innerResult) {
|
|
888
|
+
return innerResult;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
699
891
|
}
|
|
700
892
|
}
|
|
701
893
|
const allLiterals = unionAst.types.every((t) => t._tag === "Literal");
|
|
@@ -730,7 +922,7 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
730
922
|
if (ast._tag === "Suspend") {
|
|
731
923
|
const innerAst = ast.f();
|
|
732
924
|
return toGraphQLInputTypeWithRegistry(
|
|
733
|
-
|
|
925
|
+
S2__namespace.make(innerAst),
|
|
734
926
|
enumRegistry,
|
|
735
927
|
inputRegistry,
|
|
736
928
|
inputs,
|
|
@@ -747,7 +939,7 @@ function toGraphQLArgsWithRegistry(schema, enumRegistry, inputRegistry, inputs,
|
|
|
747
939
|
for (const field2 of ast.propertySignatures) {
|
|
748
940
|
const fieldName = String(field2.name);
|
|
749
941
|
if (fieldName === "_tag") continue;
|
|
750
|
-
const fieldSchema =
|
|
942
|
+
const fieldSchema = S2__namespace.make(field2.type);
|
|
751
943
|
let fieldType = toGraphQLInputTypeWithRegistry(
|
|
752
944
|
fieldSchema,
|
|
753
945
|
enumRegistry,
|
|
@@ -784,7 +976,7 @@ function isOptionSchema(schema) {
|
|
|
784
976
|
}
|
|
785
977
|
function encodeResolverOutput(schema, value) {
|
|
786
978
|
if (isOptionSchema(schema)) {
|
|
787
|
-
return effect.Effect.orDie(
|
|
979
|
+
return effect.Effect.orDie(S2__namespace.encode(schema)(value));
|
|
788
980
|
}
|
|
789
981
|
return effect.Effect.succeed(value);
|
|
790
982
|
}
|