@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/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
|
var DataLoader = require('dataloader');
|
|
8
8
|
var platform = require('@effect/platform');
|
|
@@ -27,7 +27,7 @@ function _interopNamespace(e) {
|
|
|
27
27
|
return Object.freeze(n);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var S2__namespace = /*#__PURE__*/_interopNamespace(S2);
|
|
31
31
|
var AST__namespace = /*#__PURE__*/_interopNamespace(AST);
|
|
32
32
|
var DataLoader__default = /*#__PURE__*/_interopDefault(DataLoader);
|
|
33
33
|
|
|
@@ -83,7 +83,7 @@ var toGraphQLType = (schema) => {
|
|
|
83
83
|
if (isIntegerType(ast)) {
|
|
84
84
|
return graphql.GraphQLInt;
|
|
85
85
|
}
|
|
86
|
-
return toGraphQLType(
|
|
86
|
+
return toGraphQLType(S2__namespace.make(ast.from));
|
|
87
87
|
}
|
|
88
88
|
if (ast._tag === "Literal") {
|
|
89
89
|
if (typeof ast.literal === "string") return graphql.GraphQLString;
|
|
@@ -95,7 +95,7 @@ var toGraphQLType = (schema) => {
|
|
|
95
95
|
if (ast._tag === "TupleType") {
|
|
96
96
|
const elements = ast.elements;
|
|
97
97
|
if (elements.length > 0) {
|
|
98
|
-
const elementSchema =
|
|
98
|
+
const elementSchema = S2__namespace.make(elements[0].type);
|
|
99
99
|
return new graphql.GraphQLList(toGraphQLType(elementSchema));
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -104,7 +104,7 @@ var toGraphQLType = (schema) => {
|
|
|
104
104
|
for (const field2 of ast.propertySignatures) {
|
|
105
105
|
const fieldName = String(field2.name);
|
|
106
106
|
if (fieldName === "_tag") continue;
|
|
107
|
-
const fieldSchema =
|
|
107
|
+
const fieldSchema = S2__namespace.make(field2.type);
|
|
108
108
|
let fieldType = toGraphQLType(fieldSchema);
|
|
109
109
|
if (!field2.isOptional) {
|
|
110
110
|
fieldType = new graphql.GraphQLNonNull(fieldType);
|
|
@@ -121,32 +121,32 @@ var toGraphQLType = (schema) => {
|
|
|
121
121
|
if (isOptionTransformation(ast)) {
|
|
122
122
|
const innerType = getOptionInnerType(ast.to);
|
|
123
123
|
if (innerType) {
|
|
124
|
-
return toGraphQLType(
|
|
124
|
+
return toGraphQLType(S2__namespace.make(innerType));
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
return toGraphQLType(
|
|
127
|
+
return toGraphQLType(S2__namespace.make(ast.to));
|
|
128
128
|
}
|
|
129
129
|
if (ast._tag === "Declaration") {
|
|
130
130
|
if (isOptionDeclaration(ast)) {
|
|
131
131
|
const innerType = getOptionInnerType(ast);
|
|
132
132
|
if (innerType) {
|
|
133
|
-
return toGraphQLType(
|
|
133
|
+
return toGraphQLType(S2__namespace.make(innerType));
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
const typeParams = ast.typeParameters;
|
|
137
137
|
if (typeParams && typeParams.length > 0) {
|
|
138
|
-
return toGraphQLType(
|
|
138
|
+
return toGraphQLType(S2__namespace.make(typeParams[0]));
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
if (ast._tag === "Union") {
|
|
142
142
|
const types = ast.types;
|
|
143
143
|
if (types.length > 0) {
|
|
144
|
-
return toGraphQLType(
|
|
144
|
+
return toGraphQLType(S2__namespace.make(types[0]));
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
if (ast._tag === "Suspend") {
|
|
148
148
|
const innerAst = ast.f();
|
|
149
|
-
return toGraphQLType(
|
|
149
|
+
return toGraphQLType(S2__namespace.make(innerAst));
|
|
150
150
|
}
|
|
151
151
|
return graphql.GraphQLString;
|
|
152
152
|
};
|
|
@@ -159,7 +159,7 @@ var toGraphQLInputType = (schema) => {
|
|
|
159
159
|
if (isIntegerType(ast)) {
|
|
160
160
|
return graphql.GraphQLInt;
|
|
161
161
|
}
|
|
162
|
-
return toGraphQLInputType(
|
|
162
|
+
return toGraphQLInputType(S2__namespace.make(ast.from));
|
|
163
163
|
}
|
|
164
164
|
if (ast._tag === "Literal") {
|
|
165
165
|
if (typeof ast.literal === "string") return graphql.GraphQLString;
|
|
@@ -171,7 +171,7 @@ var toGraphQLInputType = (schema) => {
|
|
|
171
171
|
if (ast._tag === "TupleType") {
|
|
172
172
|
const elements = ast.elements;
|
|
173
173
|
if (elements.length > 0) {
|
|
174
|
-
const elementSchema =
|
|
174
|
+
const elementSchema = S2__namespace.make(elements[0].type);
|
|
175
175
|
return new graphql.GraphQLList(toGraphQLInputType(elementSchema));
|
|
176
176
|
}
|
|
177
177
|
}
|
|
@@ -180,7 +180,7 @@ var toGraphQLInputType = (schema) => {
|
|
|
180
180
|
for (const field2 of ast.propertySignatures) {
|
|
181
181
|
const fieldName = String(field2.name);
|
|
182
182
|
if (fieldName === "_tag") continue;
|
|
183
|
-
const fieldSchema =
|
|
183
|
+
const fieldSchema = S2__namespace.make(field2.type);
|
|
184
184
|
let fieldType = toGraphQLInputType(fieldSchema);
|
|
185
185
|
if (!field2.isOptional) {
|
|
186
186
|
fieldType = new graphql.GraphQLNonNull(fieldType);
|
|
@@ -194,33 +194,33 @@ var toGraphQLInputType = (schema) => {
|
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
if (ast._tag === "Transformation") {
|
|
197
|
-
return toGraphQLInputType(
|
|
197
|
+
return toGraphQLInputType(S2__namespace.make(ast.from));
|
|
198
198
|
}
|
|
199
199
|
if (ast._tag === "Declaration") {
|
|
200
200
|
if (isOptionDeclaration(ast)) {
|
|
201
201
|
const innerType = getOptionInnerType(ast);
|
|
202
202
|
if (innerType) {
|
|
203
|
-
return toGraphQLInputType(
|
|
203
|
+
return toGraphQLInputType(S2__namespace.make(innerType));
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
const typeParams = ast.typeParameters;
|
|
207
207
|
if (typeParams && typeParams.length > 0) {
|
|
208
|
-
return toGraphQLInputType(
|
|
208
|
+
return toGraphQLInputType(S2__namespace.make(typeParams[0]));
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
if (ast._tag === "Union") {
|
|
212
212
|
const types = ast.types;
|
|
213
213
|
const nonNullTypes = types.filter((t) => t._tag !== "Literal" || t.literal !== null).filter((t) => t._tag !== "UndefinedKeyword");
|
|
214
214
|
if (nonNullTypes.length > 0) {
|
|
215
|
-
return toGraphQLInputType(
|
|
215
|
+
return toGraphQLInputType(S2__namespace.make(nonNullTypes[0]));
|
|
216
216
|
}
|
|
217
217
|
if (types.length > 0) {
|
|
218
|
-
return toGraphQLInputType(
|
|
218
|
+
return toGraphQLInputType(S2__namespace.make(types[0]));
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
if (ast._tag === "Suspend") {
|
|
222
222
|
const innerAst = ast.f();
|
|
223
|
-
return toGraphQLInputType(
|
|
223
|
+
return toGraphQLInputType(S2__namespace.make(innerAst));
|
|
224
224
|
}
|
|
225
225
|
return graphql.GraphQLString;
|
|
226
226
|
};
|
|
@@ -243,7 +243,7 @@ var toGraphQLObjectType = (name, schema, additionalFields) => {
|
|
|
243
243
|
for (const field2 of ast.propertySignatures) {
|
|
244
244
|
const fieldName = String(field2.name);
|
|
245
245
|
if (fieldName === "_tag") continue;
|
|
246
|
-
const fieldSchema =
|
|
246
|
+
const fieldSchema = S2__namespace.make(field2.type);
|
|
247
247
|
let fieldType = toGraphQLType(fieldSchema);
|
|
248
248
|
if (!field2.isOptional) {
|
|
249
249
|
fieldType = new graphql.GraphQLNonNull(fieldType);
|
|
@@ -275,7 +275,7 @@ var toGraphQLArgs = (schema) => {
|
|
|
275
275
|
for (const field2 of ast.propertySignatures) {
|
|
276
276
|
const fieldName = String(field2.name);
|
|
277
277
|
if (fieldName === "_tag") continue;
|
|
278
|
-
const fieldSchema =
|
|
278
|
+
const fieldSchema = S2__namespace.make(field2.type);
|
|
279
279
|
let fieldType = toGraphQLInputType(fieldSchema);
|
|
280
280
|
if (!field2.isOptional) {
|
|
281
281
|
fieldType = new graphql.GraphQLNonNull(fieldType);
|
|
@@ -403,17 +403,17 @@ function toGraphQLTypeWithRegistry(schema, ctx) {
|
|
|
403
403
|
if (isOptionDeclaration2(ast)) {
|
|
404
404
|
const innerType = getOptionInnerType2(ast);
|
|
405
405
|
if (innerType) {
|
|
406
|
-
return toGraphQLTypeWithRegistry(
|
|
406
|
+
return toGraphQLTypeWithRegistry(S2__namespace.make(innerType), ctx);
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
409
|
const typeParams = ast.typeParameters;
|
|
410
410
|
if (typeParams && typeParams.length > 0) {
|
|
411
|
-
return toGraphQLTypeWithRegistry(
|
|
411
|
+
return toGraphQLTypeWithRegistry(S2__namespace.make(typeParams[0]), ctx);
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
if (ast._tag === "Suspend") {
|
|
415
415
|
const innerAst = ast.f();
|
|
416
|
-
return toGraphQLTypeWithRegistry(
|
|
416
|
+
return toGraphQLTypeWithRegistry(S2__namespace.make(innerAst), ctx);
|
|
417
417
|
}
|
|
418
418
|
return toGraphQLType(schema);
|
|
419
419
|
}
|
|
@@ -466,6 +466,12 @@ function handleTransformationAST(ast, ctx) {
|
|
|
466
466
|
const result = ctx.typeRegistry.get(typeName);
|
|
467
467
|
if (result) return result;
|
|
468
468
|
}
|
|
469
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
470
|
+
if (typeReg.schema.ast === memberAst) {
|
|
471
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
472
|
+
if (result) return result;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
469
475
|
if (memberAst._tag === "Transformation") {
|
|
470
476
|
const innerToAst = memberAst.to;
|
|
471
477
|
const transformedTypeName = ctx.astToTypeName?.get(innerToAst);
|
|
@@ -473,26 +479,61 @@ function handleTransformationAST(ast, ctx) {
|
|
|
473
479
|
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
474
480
|
if (result) return result;
|
|
475
481
|
}
|
|
482
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
483
|
+
if (typeReg.schema.ast === innerToAst) {
|
|
484
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
485
|
+
if (result) return result;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
490
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
491
|
+
(p) => String(p.name) === "value"
|
|
492
|
+
);
|
|
493
|
+
if (valueField) {
|
|
494
|
+
const valueType = valueField.type;
|
|
495
|
+
const valueTypeName = ctx.astToTypeName?.get(valueType);
|
|
496
|
+
if (valueTypeName) {
|
|
497
|
+
const result = ctx.typeRegistry.get(valueTypeName);
|
|
498
|
+
if (result) return result;
|
|
499
|
+
}
|
|
500
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
501
|
+
if (typeReg.schema.ast === valueType) {
|
|
502
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
503
|
+
if (result) return result;
|
|
504
|
+
}
|
|
505
|
+
let regAst = typeReg.schema.ast;
|
|
506
|
+
while (regAst._tag === "Transformation") {
|
|
507
|
+
regAst = regAst.to;
|
|
508
|
+
if (regAst === valueType) {
|
|
509
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
510
|
+
if (result) return result;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
const innerResult = toGraphQLTypeWithRegistry(S2__namespace.make(valueType), ctx);
|
|
515
|
+
if (innerResult) return innerResult;
|
|
516
|
+
}
|
|
476
517
|
}
|
|
477
518
|
}
|
|
478
519
|
}
|
|
479
520
|
const innerType = getOptionInnerType2(toAst);
|
|
480
521
|
if (innerType) {
|
|
481
|
-
return toGraphQLTypeWithRegistry(
|
|
522
|
+
return toGraphQLTypeWithRegistry(S2__namespace.make(innerType), ctx);
|
|
482
523
|
}
|
|
483
524
|
}
|
|
484
525
|
if (toAst._tag === "TupleType") {
|
|
485
526
|
if (toAst.rest && toAst.rest.length > 0) {
|
|
486
|
-
const elementSchema =
|
|
527
|
+
const elementSchema = S2__namespace.make(toAst.rest[0].type);
|
|
487
528
|
const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
|
|
488
529
|
return new graphql.GraphQLList(elementType);
|
|
489
530
|
} else if (toAst.elements.length > 0) {
|
|
490
|
-
const elementSchema =
|
|
531
|
+
const elementSchema = S2__namespace.make(toAst.elements[0].type);
|
|
491
532
|
const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
|
|
492
533
|
return new graphql.GraphQLList(elementType);
|
|
493
534
|
}
|
|
494
535
|
}
|
|
495
|
-
return toGraphQLTypeWithRegistry(
|
|
536
|
+
return toGraphQLTypeWithRegistry(S2__namespace.make(ast.to), ctx);
|
|
496
537
|
}
|
|
497
538
|
function handleUnionAST(ast, ctx) {
|
|
498
539
|
const allLiterals = ast.types.every((t) => t._tag === "Literal");
|
|
@@ -509,6 +550,12 @@ function handleUnionAST(ast, ctx) {
|
|
|
509
550
|
const result = ctx.typeRegistry.get(typeName);
|
|
510
551
|
if (result) return result;
|
|
511
552
|
}
|
|
553
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
554
|
+
if (typeReg.schema.ast === memberAst) {
|
|
555
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
556
|
+
if (result) return result;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
512
559
|
if (memberAst._tag === "Transformation") {
|
|
513
560
|
const toAst = memberAst.to;
|
|
514
561
|
const transformedTypeName = ctx.astToTypeName?.get(toAst);
|
|
@@ -516,12 +563,49 @@ function handleUnionAST(ast, ctx) {
|
|
|
516
563
|
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
517
564
|
if (result) return result;
|
|
518
565
|
}
|
|
566
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
567
|
+
if (typeReg.schema.ast === toAst) {
|
|
568
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
569
|
+
if (result) return result;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
574
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
575
|
+
(p) => String(p.name) === "value"
|
|
576
|
+
);
|
|
577
|
+
if (valueField) {
|
|
578
|
+
const valueType = valueField.type;
|
|
579
|
+
const valueTypeName = ctx.astToTypeName?.get(valueType);
|
|
580
|
+
if (valueTypeName) {
|
|
581
|
+
const result = ctx.typeRegistry.get(valueTypeName);
|
|
582
|
+
if (result) return result;
|
|
583
|
+
}
|
|
584
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
585
|
+
if (typeReg.schema.ast === valueType) {
|
|
586
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
587
|
+
if (result) return result;
|
|
588
|
+
}
|
|
589
|
+
let regAst = typeReg.schema.ast;
|
|
590
|
+
while (regAst._tag === "Transformation") {
|
|
591
|
+
regAst = regAst.to;
|
|
592
|
+
if (regAst === valueType) {
|
|
593
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
594
|
+
if (result) return result;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
const innerResult = toGraphQLTypeWithRegistry(S2__namespace.make(valueType), ctx);
|
|
599
|
+
if (innerResult) {
|
|
600
|
+
return innerResult;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
519
603
|
}
|
|
520
604
|
}
|
|
521
605
|
if (ast.types.length > 0) {
|
|
522
|
-
return toGraphQLTypeWithRegistry(
|
|
606
|
+
return toGraphQLTypeWithRegistry(S2__namespace.make(ast.types[0]), ctx);
|
|
523
607
|
}
|
|
524
|
-
return toGraphQLType(
|
|
608
|
+
return toGraphQLType(S2__namespace.make(ast));
|
|
525
609
|
}
|
|
526
610
|
function findEnumForLiteralUnion(types, ctx) {
|
|
527
611
|
const literalValues = types.map((t) => String(t.literal)).sort();
|
|
@@ -564,15 +648,15 @@ function findEnumForLiteral(ast, ctx) {
|
|
|
564
648
|
}
|
|
565
649
|
function handleTupleTypeAST(ast, ctx) {
|
|
566
650
|
if (ast.rest && ast.rest.length > 0) {
|
|
567
|
-
const elementSchema =
|
|
651
|
+
const elementSchema = S2__namespace.make(ast.rest[0].type);
|
|
568
652
|
const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
|
|
569
653
|
return new graphql.GraphQLList(elementType);
|
|
570
654
|
} else if (ast.elements && ast.elements.length > 0) {
|
|
571
|
-
const elementSchema =
|
|
655
|
+
const elementSchema = S2__namespace.make(ast.elements[0].type);
|
|
572
656
|
const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
|
|
573
657
|
return new graphql.GraphQLList(elementType);
|
|
574
658
|
}
|
|
575
|
-
return toGraphQLType(
|
|
659
|
+
return toGraphQLType(S2__namespace.make(ast));
|
|
576
660
|
}
|
|
577
661
|
function schemaToFields(schema, ctx) {
|
|
578
662
|
let ast = schema.ast;
|
|
@@ -596,7 +680,7 @@ function schemaToFields(schema, ctx) {
|
|
|
596
680
|
for (const field2 of ast.propertySignatures) {
|
|
597
681
|
const fieldName = String(field2.name);
|
|
598
682
|
if (fieldName === "_tag") continue;
|
|
599
|
-
const fieldSchema =
|
|
683
|
+
const fieldSchema = S2__namespace.make(field2.type);
|
|
600
684
|
let fieldType = toGraphQLTypeWithRegistry(fieldSchema, ctx);
|
|
601
685
|
if (!field2.isOptional) {
|
|
602
686
|
fieldType = getNonNull(fieldType);
|
|
@@ -617,7 +701,7 @@ function schemaToInputFields(schema, enumRegistry, inputRegistry, inputs, enums,
|
|
|
617
701
|
for (const field2 of ast.propertySignatures) {
|
|
618
702
|
const fieldName = String(field2.name);
|
|
619
703
|
if (fieldName === "_tag") continue;
|
|
620
|
-
const fieldSchema =
|
|
704
|
+
const fieldSchema = S2__namespace.make(field2.type);
|
|
621
705
|
let fieldType = toGraphQLInputTypeWithRegistry(
|
|
622
706
|
fieldSchema,
|
|
623
707
|
enumRegistry,
|
|
@@ -690,6 +774,12 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
690
774
|
const result = inputRegistry.get(inputName);
|
|
691
775
|
if (result) return result;
|
|
692
776
|
}
|
|
777
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
778
|
+
if (inputReg.schema.ast === memberAst) {
|
|
779
|
+
const result = inputRegistry.get(regInputName);
|
|
780
|
+
if (result) return result;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
693
783
|
if (memberAst._tag === "Transformation") {
|
|
694
784
|
const innerToAst = memberAst.to;
|
|
695
785
|
const transformedInputName = cache?.astToInputName?.get(innerToAst);
|
|
@@ -697,11 +787,59 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
697
787
|
const result = inputRegistry.get(transformedInputName);
|
|
698
788
|
if (result) return result;
|
|
699
789
|
}
|
|
790
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
791
|
+
if (inputReg.schema.ast === innerToAst) {
|
|
792
|
+
const result = inputRegistry.get(regInputName);
|
|
793
|
+
if (result) return result;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
798
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
799
|
+
(p) => String(p.name) === "value"
|
|
800
|
+
);
|
|
801
|
+
if (valueField) {
|
|
802
|
+
const valueType = valueField.type;
|
|
803
|
+
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
804
|
+
if (valueInputName) {
|
|
805
|
+
const result = inputRegistry.get(valueInputName);
|
|
806
|
+
if (result) return result;
|
|
807
|
+
}
|
|
808
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
809
|
+
if (inputReg.schema.ast === valueType) {
|
|
810
|
+
const result = inputRegistry.get(regInputName);
|
|
811
|
+
if (result) return result;
|
|
812
|
+
}
|
|
813
|
+
let regAst = inputReg.schema.ast;
|
|
814
|
+
while (regAst._tag === "Transformation") {
|
|
815
|
+
regAst = regAst.to;
|
|
816
|
+
if (regAst === valueType) {
|
|
817
|
+
const result = inputRegistry.get(regInputName);
|
|
818
|
+
if (result) return result;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
822
|
+
const result = inputRegistry.get(regInputName);
|
|
823
|
+
if (result) return result;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
827
|
+
S2__namespace.make(valueType),
|
|
828
|
+
enumRegistry,
|
|
829
|
+
inputRegistry,
|
|
830
|
+
inputs,
|
|
831
|
+
enums,
|
|
832
|
+
cache
|
|
833
|
+
);
|
|
834
|
+
if (innerResult) {
|
|
835
|
+
return innerResult;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
700
838
|
}
|
|
701
839
|
}
|
|
702
840
|
}
|
|
703
841
|
return toGraphQLInputTypeWithRegistry(
|
|
704
|
-
|
|
842
|
+
S2__namespace.make(toAst),
|
|
705
843
|
enumRegistry,
|
|
706
844
|
inputRegistry,
|
|
707
845
|
inputs,
|
|
@@ -714,7 +852,7 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
714
852
|
const nonUndefinedTypes = unionAst.types.filter((t) => t._tag !== "UndefinedKeyword");
|
|
715
853
|
if (nonUndefinedTypes.length === 1 && nonUndefinedTypes[0]._tag === "Union") {
|
|
716
854
|
return toGraphQLInputTypeWithRegistry(
|
|
717
|
-
|
|
855
|
+
S2__namespace.make(nonUndefinedTypes[0]),
|
|
718
856
|
enumRegistry,
|
|
719
857
|
inputRegistry,
|
|
720
858
|
inputs,
|
|
@@ -724,7 +862,7 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
724
862
|
}
|
|
725
863
|
if (nonUndefinedTypes.length === 1 && nonUndefinedTypes[0]._tag === "TypeLiteral") {
|
|
726
864
|
return toGraphQLInputTypeWithRegistry(
|
|
727
|
-
|
|
865
|
+
S2__namespace.make(nonUndefinedTypes[0]),
|
|
728
866
|
enumRegistry,
|
|
729
867
|
inputRegistry,
|
|
730
868
|
inputs,
|
|
@@ -738,6 +876,12 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
738
876
|
const result = inputRegistry.get(inputName);
|
|
739
877
|
if (result) return result;
|
|
740
878
|
}
|
|
879
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
880
|
+
if (inputReg.schema.ast === memberAst) {
|
|
881
|
+
const result = inputRegistry.get(regInputName);
|
|
882
|
+
if (result) return result;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
741
885
|
if (memberAst._tag === "Transformation") {
|
|
742
886
|
const toAst = memberAst.to;
|
|
743
887
|
const transformedInputName = cache?.astToInputName?.get(toAst);
|
|
@@ -745,6 +889,54 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
745
889
|
const result = inputRegistry.get(transformedInputName);
|
|
746
890
|
if (result) return result;
|
|
747
891
|
}
|
|
892
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
893
|
+
if (inputReg.schema.ast === toAst) {
|
|
894
|
+
const result = inputRegistry.get(regInputName);
|
|
895
|
+
if (result) return result;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
900
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
901
|
+
(p) => String(p.name) === "value"
|
|
902
|
+
);
|
|
903
|
+
if (valueField) {
|
|
904
|
+
const valueType = valueField.type;
|
|
905
|
+
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
906
|
+
if (valueInputName) {
|
|
907
|
+
const result = inputRegistry.get(valueInputName);
|
|
908
|
+
if (result) return result;
|
|
909
|
+
}
|
|
910
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
911
|
+
if (inputReg.schema.ast === valueType) {
|
|
912
|
+
const result = inputRegistry.get(regInputName);
|
|
913
|
+
if (result) return result;
|
|
914
|
+
}
|
|
915
|
+
let regAst = inputReg.schema.ast;
|
|
916
|
+
while (regAst._tag === "Transformation") {
|
|
917
|
+
regAst = regAst.to;
|
|
918
|
+
if (regAst === valueType) {
|
|
919
|
+
const result = inputRegistry.get(regInputName);
|
|
920
|
+
if (result) return result;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
924
|
+
const result = inputRegistry.get(regInputName);
|
|
925
|
+
if (result) return result;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
929
|
+
S2__namespace.make(valueType),
|
|
930
|
+
enumRegistry,
|
|
931
|
+
inputRegistry,
|
|
932
|
+
inputs,
|
|
933
|
+
enums,
|
|
934
|
+
cache
|
|
935
|
+
);
|
|
936
|
+
if (innerResult) {
|
|
937
|
+
return innerResult;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
748
940
|
}
|
|
749
941
|
}
|
|
750
942
|
const allLiterals = unionAst.types.every((t) => t._tag === "Literal");
|
|
@@ -779,7 +971,7 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
779
971
|
if (ast._tag === "Suspend") {
|
|
780
972
|
const innerAst = ast.f();
|
|
781
973
|
return toGraphQLInputTypeWithRegistry(
|
|
782
|
-
|
|
974
|
+
S2__namespace.make(innerAst),
|
|
783
975
|
enumRegistry,
|
|
784
976
|
inputRegistry,
|
|
785
977
|
inputs,
|
|
@@ -796,7 +988,7 @@ function toGraphQLArgsWithRegistry(schema, enumRegistry, inputRegistry, inputs,
|
|
|
796
988
|
for (const field2 of ast.propertySignatures) {
|
|
797
989
|
const fieldName = String(field2.name);
|
|
798
990
|
if (fieldName === "_tag") continue;
|
|
799
|
-
const fieldSchema =
|
|
991
|
+
const fieldSchema = S2__namespace.make(field2.type);
|
|
800
992
|
let fieldType = toGraphQLInputTypeWithRegistry(
|
|
801
993
|
fieldSchema,
|
|
802
994
|
enumRegistry,
|
|
@@ -833,7 +1025,7 @@ function isOptionSchema(schema) {
|
|
|
833
1025
|
}
|
|
834
1026
|
function encodeResolverOutput(schema, value) {
|
|
835
1027
|
if (isOptionSchema(schema)) {
|
|
836
|
-
return effect.Effect.orDie(
|
|
1028
|
+
return effect.Effect.orDie(S2__namespace.encode(schema)(value));
|
|
837
1029
|
}
|
|
838
1030
|
return effect.Effect.succeed(value);
|
|
839
1031
|
}
|