@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.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, Kind, specifiedRules, NoSchemaIntrospectionCustomRule, subscribe, GraphQLScalarType } from 'graphql';
|
|
2
2
|
export { DirectiveLocation, GraphQLBoolean, GraphQLEnumType, GraphQLFloat, GraphQLID, GraphQLInputObjectType, GraphQLInt, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, GraphQLSchema, GraphQLString, GraphQLUnionType, Kind, graphql, lexicographicSortSchema, printSchema } from 'graphql';
|
|
3
3
|
import { Pipeable, Context, Data, Layer, Effect, Ref, HashMap, Config, Option, Schema, Runtime, Queue, Stream, Fiber, Deferred } from 'effect';
|
|
4
|
-
import * as
|
|
4
|
+
import * as S2 from 'effect/Schema';
|
|
5
5
|
import * as AST from 'effect/SchemaAST';
|
|
6
6
|
import DataLoader from 'dataloader';
|
|
7
7
|
import { HttpIncomingMessage, HttpServerResponse, HttpServerRequest, HttpRouter } from '@effect/platform';
|
|
@@ -58,7 +58,7 @@ var toGraphQLType = (schema) => {
|
|
|
58
58
|
if (isIntegerType(ast)) {
|
|
59
59
|
return GraphQLInt;
|
|
60
60
|
}
|
|
61
|
-
return toGraphQLType(
|
|
61
|
+
return toGraphQLType(S2.make(ast.from));
|
|
62
62
|
}
|
|
63
63
|
if (ast._tag === "Literal") {
|
|
64
64
|
if (typeof ast.literal === "string") return GraphQLString;
|
|
@@ -70,7 +70,7 @@ var toGraphQLType = (schema) => {
|
|
|
70
70
|
if (ast._tag === "TupleType") {
|
|
71
71
|
const elements = ast.elements;
|
|
72
72
|
if (elements.length > 0) {
|
|
73
|
-
const elementSchema =
|
|
73
|
+
const elementSchema = S2.make(elements[0].type);
|
|
74
74
|
return new GraphQLList(toGraphQLType(elementSchema));
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -79,7 +79,7 @@ var toGraphQLType = (schema) => {
|
|
|
79
79
|
for (const field2 of ast.propertySignatures) {
|
|
80
80
|
const fieldName = String(field2.name);
|
|
81
81
|
if (fieldName === "_tag") continue;
|
|
82
|
-
const fieldSchema =
|
|
82
|
+
const fieldSchema = S2.make(field2.type);
|
|
83
83
|
let fieldType = toGraphQLType(fieldSchema);
|
|
84
84
|
if (!field2.isOptional) {
|
|
85
85
|
fieldType = new GraphQLNonNull(fieldType);
|
|
@@ -96,32 +96,32 @@ var toGraphQLType = (schema) => {
|
|
|
96
96
|
if (isOptionTransformation(ast)) {
|
|
97
97
|
const innerType = getOptionInnerType(ast.to);
|
|
98
98
|
if (innerType) {
|
|
99
|
-
return toGraphQLType(
|
|
99
|
+
return toGraphQLType(S2.make(innerType));
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
return toGraphQLType(
|
|
102
|
+
return toGraphQLType(S2.make(ast.to));
|
|
103
103
|
}
|
|
104
104
|
if (ast._tag === "Declaration") {
|
|
105
105
|
if (isOptionDeclaration(ast)) {
|
|
106
106
|
const innerType = getOptionInnerType(ast);
|
|
107
107
|
if (innerType) {
|
|
108
|
-
return toGraphQLType(
|
|
108
|
+
return toGraphQLType(S2.make(innerType));
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
const typeParams = ast.typeParameters;
|
|
112
112
|
if (typeParams && typeParams.length > 0) {
|
|
113
|
-
return toGraphQLType(
|
|
113
|
+
return toGraphQLType(S2.make(typeParams[0]));
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
if (ast._tag === "Union") {
|
|
117
117
|
const types = ast.types;
|
|
118
118
|
if (types.length > 0) {
|
|
119
|
-
return toGraphQLType(
|
|
119
|
+
return toGraphQLType(S2.make(types[0]));
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
if (ast._tag === "Suspend") {
|
|
123
123
|
const innerAst = ast.f();
|
|
124
|
-
return toGraphQLType(
|
|
124
|
+
return toGraphQLType(S2.make(innerAst));
|
|
125
125
|
}
|
|
126
126
|
return GraphQLString;
|
|
127
127
|
};
|
|
@@ -134,7 +134,7 @@ var toGraphQLInputType = (schema) => {
|
|
|
134
134
|
if (isIntegerType(ast)) {
|
|
135
135
|
return GraphQLInt;
|
|
136
136
|
}
|
|
137
|
-
return toGraphQLInputType(
|
|
137
|
+
return toGraphQLInputType(S2.make(ast.from));
|
|
138
138
|
}
|
|
139
139
|
if (ast._tag === "Literal") {
|
|
140
140
|
if (typeof ast.literal === "string") return GraphQLString;
|
|
@@ -146,7 +146,7 @@ var toGraphQLInputType = (schema) => {
|
|
|
146
146
|
if (ast._tag === "TupleType") {
|
|
147
147
|
const elements = ast.elements;
|
|
148
148
|
if (elements.length > 0) {
|
|
149
|
-
const elementSchema =
|
|
149
|
+
const elementSchema = S2.make(elements[0].type);
|
|
150
150
|
return new GraphQLList(toGraphQLInputType(elementSchema));
|
|
151
151
|
}
|
|
152
152
|
}
|
|
@@ -155,7 +155,7 @@ var toGraphQLInputType = (schema) => {
|
|
|
155
155
|
for (const field2 of ast.propertySignatures) {
|
|
156
156
|
const fieldName = String(field2.name);
|
|
157
157
|
if (fieldName === "_tag") continue;
|
|
158
|
-
const fieldSchema =
|
|
158
|
+
const fieldSchema = S2.make(field2.type);
|
|
159
159
|
let fieldType = toGraphQLInputType(fieldSchema);
|
|
160
160
|
if (!field2.isOptional) {
|
|
161
161
|
fieldType = new GraphQLNonNull(fieldType);
|
|
@@ -169,33 +169,33 @@ var toGraphQLInputType = (schema) => {
|
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
171
|
if (ast._tag === "Transformation") {
|
|
172
|
-
return toGraphQLInputType(
|
|
172
|
+
return toGraphQLInputType(S2.make(ast.from));
|
|
173
173
|
}
|
|
174
174
|
if (ast._tag === "Declaration") {
|
|
175
175
|
if (isOptionDeclaration(ast)) {
|
|
176
176
|
const innerType = getOptionInnerType(ast);
|
|
177
177
|
if (innerType) {
|
|
178
|
-
return toGraphQLInputType(
|
|
178
|
+
return toGraphQLInputType(S2.make(innerType));
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
const typeParams = ast.typeParameters;
|
|
182
182
|
if (typeParams && typeParams.length > 0) {
|
|
183
|
-
return toGraphQLInputType(
|
|
183
|
+
return toGraphQLInputType(S2.make(typeParams[0]));
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
if (ast._tag === "Union") {
|
|
187
187
|
const types = ast.types;
|
|
188
188
|
const nonNullTypes = types.filter((t) => t._tag !== "Literal" || t.literal !== null).filter((t) => t._tag !== "UndefinedKeyword");
|
|
189
189
|
if (nonNullTypes.length > 0) {
|
|
190
|
-
return toGraphQLInputType(
|
|
190
|
+
return toGraphQLInputType(S2.make(nonNullTypes[0]));
|
|
191
191
|
}
|
|
192
192
|
if (types.length > 0) {
|
|
193
|
-
return toGraphQLInputType(
|
|
193
|
+
return toGraphQLInputType(S2.make(types[0]));
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
if (ast._tag === "Suspend") {
|
|
197
197
|
const innerAst = ast.f();
|
|
198
|
-
return toGraphQLInputType(
|
|
198
|
+
return toGraphQLInputType(S2.make(innerAst));
|
|
199
199
|
}
|
|
200
200
|
return GraphQLString;
|
|
201
201
|
};
|
|
@@ -218,7 +218,7 @@ var toGraphQLObjectType = (name, schema, additionalFields) => {
|
|
|
218
218
|
for (const field2 of ast.propertySignatures) {
|
|
219
219
|
const fieldName = String(field2.name);
|
|
220
220
|
if (fieldName === "_tag") continue;
|
|
221
|
-
const fieldSchema =
|
|
221
|
+
const fieldSchema = S2.make(field2.type);
|
|
222
222
|
let fieldType = toGraphQLType(fieldSchema);
|
|
223
223
|
if (!field2.isOptional) {
|
|
224
224
|
fieldType = new GraphQLNonNull(fieldType);
|
|
@@ -250,7 +250,7 @@ var toGraphQLArgs = (schema) => {
|
|
|
250
250
|
for (const field2 of ast.propertySignatures) {
|
|
251
251
|
const fieldName = String(field2.name);
|
|
252
252
|
if (fieldName === "_tag") continue;
|
|
253
|
-
const fieldSchema =
|
|
253
|
+
const fieldSchema = S2.make(field2.type);
|
|
254
254
|
let fieldType = toGraphQLInputType(fieldSchema);
|
|
255
255
|
if (!field2.isOptional) {
|
|
256
256
|
fieldType = new GraphQLNonNull(fieldType);
|
|
@@ -378,17 +378,17 @@ function toGraphQLTypeWithRegistry(schema, ctx) {
|
|
|
378
378
|
if (isOptionDeclaration2(ast)) {
|
|
379
379
|
const innerType = getOptionInnerType2(ast);
|
|
380
380
|
if (innerType) {
|
|
381
|
-
return toGraphQLTypeWithRegistry(
|
|
381
|
+
return toGraphQLTypeWithRegistry(S2.make(innerType), ctx);
|
|
382
382
|
}
|
|
383
383
|
}
|
|
384
384
|
const typeParams = ast.typeParameters;
|
|
385
385
|
if (typeParams && typeParams.length > 0) {
|
|
386
|
-
return toGraphQLTypeWithRegistry(
|
|
386
|
+
return toGraphQLTypeWithRegistry(S2.make(typeParams[0]), ctx);
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
if (ast._tag === "Suspend") {
|
|
390
390
|
const innerAst = ast.f();
|
|
391
|
-
return toGraphQLTypeWithRegistry(
|
|
391
|
+
return toGraphQLTypeWithRegistry(S2.make(innerAst), ctx);
|
|
392
392
|
}
|
|
393
393
|
return toGraphQLType(schema);
|
|
394
394
|
}
|
|
@@ -441,6 +441,12 @@ function handleTransformationAST(ast, ctx) {
|
|
|
441
441
|
const result = ctx.typeRegistry.get(typeName);
|
|
442
442
|
if (result) return result;
|
|
443
443
|
}
|
|
444
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
445
|
+
if (typeReg.schema.ast === memberAst) {
|
|
446
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
447
|
+
if (result) return result;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
444
450
|
if (memberAst._tag === "Transformation") {
|
|
445
451
|
const innerToAst = memberAst.to;
|
|
446
452
|
const transformedTypeName = ctx.astToTypeName?.get(innerToAst);
|
|
@@ -448,26 +454,61 @@ function handleTransformationAST(ast, ctx) {
|
|
|
448
454
|
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
449
455
|
if (result) return result;
|
|
450
456
|
}
|
|
457
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
458
|
+
if (typeReg.schema.ast === innerToAst) {
|
|
459
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
460
|
+
if (result) return result;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
465
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
466
|
+
(p) => String(p.name) === "value"
|
|
467
|
+
);
|
|
468
|
+
if (valueField) {
|
|
469
|
+
const valueType = valueField.type;
|
|
470
|
+
const valueTypeName = ctx.astToTypeName?.get(valueType);
|
|
471
|
+
if (valueTypeName) {
|
|
472
|
+
const result = ctx.typeRegistry.get(valueTypeName);
|
|
473
|
+
if (result) return result;
|
|
474
|
+
}
|
|
475
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
476
|
+
if (typeReg.schema.ast === valueType) {
|
|
477
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
478
|
+
if (result) return result;
|
|
479
|
+
}
|
|
480
|
+
let regAst = typeReg.schema.ast;
|
|
481
|
+
while (regAst._tag === "Transformation") {
|
|
482
|
+
regAst = regAst.to;
|
|
483
|
+
if (regAst === valueType) {
|
|
484
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
485
|
+
if (result) return result;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
const innerResult = toGraphQLTypeWithRegistry(S2.make(valueType), ctx);
|
|
490
|
+
if (innerResult) return innerResult;
|
|
491
|
+
}
|
|
451
492
|
}
|
|
452
493
|
}
|
|
453
494
|
}
|
|
454
495
|
const innerType = getOptionInnerType2(toAst);
|
|
455
496
|
if (innerType) {
|
|
456
|
-
return toGraphQLTypeWithRegistry(
|
|
497
|
+
return toGraphQLTypeWithRegistry(S2.make(innerType), ctx);
|
|
457
498
|
}
|
|
458
499
|
}
|
|
459
500
|
if (toAst._tag === "TupleType") {
|
|
460
501
|
if (toAst.rest && toAst.rest.length > 0) {
|
|
461
|
-
const elementSchema =
|
|
502
|
+
const elementSchema = S2.make(toAst.rest[0].type);
|
|
462
503
|
const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
|
|
463
504
|
return new GraphQLList(elementType);
|
|
464
505
|
} else if (toAst.elements.length > 0) {
|
|
465
|
-
const elementSchema =
|
|
506
|
+
const elementSchema = S2.make(toAst.elements[0].type);
|
|
466
507
|
const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
|
|
467
508
|
return new GraphQLList(elementType);
|
|
468
509
|
}
|
|
469
510
|
}
|
|
470
|
-
return toGraphQLTypeWithRegistry(
|
|
511
|
+
return toGraphQLTypeWithRegistry(S2.make(ast.to), ctx);
|
|
471
512
|
}
|
|
472
513
|
function handleUnionAST(ast, ctx) {
|
|
473
514
|
const allLiterals = ast.types.every((t) => t._tag === "Literal");
|
|
@@ -484,6 +525,12 @@ function handleUnionAST(ast, ctx) {
|
|
|
484
525
|
const result = ctx.typeRegistry.get(typeName);
|
|
485
526
|
if (result) return result;
|
|
486
527
|
}
|
|
528
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
529
|
+
if (typeReg.schema.ast === memberAst) {
|
|
530
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
531
|
+
if (result) return result;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
487
534
|
if (memberAst._tag === "Transformation") {
|
|
488
535
|
const toAst = memberAst.to;
|
|
489
536
|
const transformedTypeName = ctx.astToTypeName?.get(toAst);
|
|
@@ -491,12 +538,49 @@ function handleUnionAST(ast, ctx) {
|
|
|
491
538
|
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
492
539
|
if (result) return result;
|
|
493
540
|
}
|
|
541
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
542
|
+
if (typeReg.schema.ast === toAst) {
|
|
543
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
544
|
+
if (result) return result;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
549
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
550
|
+
(p) => String(p.name) === "value"
|
|
551
|
+
);
|
|
552
|
+
if (valueField) {
|
|
553
|
+
const valueType = valueField.type;
|
|
554
|
+
const valueTypeName = ctx.astToTypeName?.get(valueType);
|
|
555
|
+
if (valueTypeName) {
|
|
556
|
+
const result = ctx.typeRegistry.get(valueTypeName);
|
|
557
|
+
if (result) return result;
|
|
558
|
+
}
|
|
559
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
560
|
+
if (typeReg.schema.ast === valueType) {
|
|
561
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
562
|
+
if (result) return result;
|
|
563
|
+
}
|
|
564
|
+
let regAst = typeReg.schema.ast;
|
|
565
|
+
while (regAst._tag === "Transformation") {
|
|
566
|
+
regAst = regAst.to;
|
|
567
|
+
if (regAst === valueType) {
|
|
568
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
569
|
+
if (result) return result;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
const innerResult = toGraphQLTypeWithRegistry(S2.make(valueType), ctx);
|
|
574
|
+
if (innerResult) {
|
|
575
|
+
return innerResult;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
494
578
|
}
|
|
495
579
|
}
|
|
496
580
|
if (ast.types.length > 0) {
|
|
497
|
-
return toGraphQLTypeWithRegistry(
|
|
581
|
+
return toGraphQLTypeWithRegistry(S2.make(ast.types[0]), ctx);
|
|
498
582
|
}
|
|
499
|
-
return toGraphQLType(
|
|
583
|
+
return toGraphQLType(S2.make(ast));
|
|
500
584
|
}
|
|
501
585
|
function findEnumForLiteralUnion(types, ctx) {
|
|
502
586
|
const literalValues = types.map((t) => String(t.literal)).sort();
|
|
@@ -539,15 +623,15 @@ function findEnumForLiteral(ast, ctx) {
|
|
|
539
623
|
}
|
|
540
624
|
function handleTupleTypeAST(ast, ctx) {
|
|
541
625
|
if (ast.rest && ast.rest.length > 0) {
|
|
542
|
-
const elementSchema =
|
|
626
|
+
const elementSchema = S2.make(ast.rest[0].type);
|
|
543
627
|
const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
|
|
544
628
|
return new GraphQLList(elementType);
|
|
545
629
|
} else if (ast.elements && ast.elements.length > 0) {
|
|
546
|
-
const elementSchema =
|
|
630
|
+
const elementSchema = S2.make(ast.elements[0].type);
|
|
547
631
|
const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
|
|
548
632
|
return new GraphQLList(elementType);
|
|
549
633
|
}
|
|
550
|
-
return toGraphQLType(
|
|
634
|
+
return toGraphQLType(S2.make(ast));
|
|
551
635
|
}
|
|
552
636
|
function schemaToFields(schema, ctx) {
|
|
553
637
|
let ast = schema.ast;
|
|
@@ -571,7 +655,7 @@ function schemaToFields(schema, ctx) {
|
|
|
571
655
|
for (const field2 of ast.propertySignatures) {
|
|
572
656
|
const fieldName = String(field2.name);
|
|
573
657
|
if (fieldName === "_tag") continue;
|
|
574
|
-
const fieldSchema =
|
|
658
|
+
const fieldSchema = S2.make(field2.type);
|
|
575
659
|
let fieldType = toGraphQLTypeWithRegistry(fieldSchema, ctx);
|
|
576
660
|
if (!field2.isOptional) {
|
|
577
661
|
fieldType = getNonNull(fieldType);
|
|
@@ -592,7 +676,7 @@ function schemaToInputFields(schema, enumRegistry, inputRegistry, inputs, enums,
|
|
|
592
676
|
for (const field2 of ast.propertySignatures) {
|
|
593
677
|
const fieldName = String(field2.name);
|
|
594
678
|
if (fieldName === "_tag") continue;
|
|
595
|
-
const fieldSchema =
|
|
679
|
+
const fieldSchema = S2.make(field2.type);
|
|
596
680
|
let fieldType = toGraphQLInputTypeWithRegistry(
|
|
597
681
|
fieldSchema,
|
|
598
682
|
enumRegistry,
|
|
@@ -665,6 +749,12 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
665
749
|
const result = inputRegistry.get(inputName);
|
|
666
750
|
if (result) return result;
|
|
667
751
|
}
|
|
752
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
753
|
+
if (inputReg.schema.ast === memberAst) {
|
|
754
|
+
const result = inputRegistry.get(regInputName);
|
|
755
|
+
if (result) return result;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
668
758
|
if (memberAst._tag === "Transformation") {
|
|
669
759
|
const innerToAst = memberAst.to;
|
|
670
760
|
const transformedInputName = cache?.astToInputName?.get(innerToAst);
|
|
@@ -672,11 +762,59 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
672
762
|
const result = inputRegistry.get(transformedInputName);
|
|
673
763
|
if (result) return result;
|
|
674
764
|
}
|
|
765
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
766
|
+
if (inputReg.schema.ast === innerToAst) {
|
|
767
|
+
const result = inputRegistry.get(regInputName);
|
|
768
|
+
if (result) return result;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
773
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
774
|
+
(p) => String(p.name) === "value"
|
|
775
|
+
);
|
|
776
|
+
if (valueField) {
|
|
777
|
+
const valueType = valueField.type;
|
|
778
|
+
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
779
|
+
if (valueInputName) {
|
|
780
|
+
const result = inputRegistry.get(valueInputName);
|
|
781
|
+
if (result) return result;
|
|
782
|
+
}
|
|
783
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
784
|
+
if (inputReg.schema.ast === valueType) {
|
|
785
|
+
const result = inputRegistry.get(regInputName);
|
|
786
|
+
if (result) return result;
|
|
787
|
+
}
|
|
788
|
+
let regAst = inputReg.schema.ast;
|
|
789
|
+
while (regAst._tag === "Transformation") {
|
|
790
|
+
regAst = regAst.to;
|
|
791
|
+
if (regAst === valueType) {
|
|
792
|
+
const result = inputRegistry.get(regInputName);
|
|
793
|
+
if (result) return result;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
797
|
+
const result = inputRegistry.get(regInputName);
|
|
798
|
+
if (result) return result;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
802
|
+
S2.make(valueType),
|
|
803
|
+
enumRegistry,
|
|
804
|
+
inputRegistry,
|
|
805
|
+
inputs,
|
|
806
|
+
enums,
|
|
807
|
+
cache
|
|
808
|
+
);
|
|
809
|
+
if (innerResult) {
|
|
810
|
+
return innerResult;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
675
813
|
}
|
|
676
814
|
}
|
|
677
815
|
}
|
|
678
816
|
return toGraphQLInputTypeWithRegistry(
|
|
679
|
-
|
|
817
|
+
S2.make(toAst),
|
|
680
818
|
enumRegistry,
|
|
681
819
|
inputRegistry,
|
|
682
820
|
inputs,
|
|
@@ -689,7 +827,7 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
689
827
|
const nonUndefinedTypes = unionAst.types.filter((t) => t._tag !== "UndefinedKeyword");
|
|
690
828
|
if (nonUndefinedTypes.length === 1 && nonUndefinedTypes[0]._tag === "Union") {
|
|
691
829
|
return toGraphQLInputTypeWithRegistry(
|
|
692
|
-
|
|
830
|
+
S2.make(nonUndefinedTypes[0]),
|
|
693
831
|
enumRegistry,
|
|
694
832
|
inputRegistry,
|
|
695
833
|
inputs,
|
|
@@ -699,7 +837,7 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
699
837
|
}
|
|
700
838
|
if (nonUndefinedTypes.length === 1 && nonUndefinedTypes[0]._tag === "TypeLiteral") {
|
|
701
839
|
return toGraphQLInputTypeWithRegistry(
|
|
702
|
-
|
|
840
|
+
S2.make(nonUndefinedTypes[0]),
|
|
703
841
|
enumRegistry,
|
|
704
842
|
inputRegistry,
|
|
705
843
|
inputs,
|
|
@@ -713,6 +851,12 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
713
851
|
const result = inputRegistry.get(inputName);
|
|
714
852
|
if (result) return result;
|
|
715
853
|
}
|
|
854
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
855
|
+
if (inputReg.schema.ast === memberAst) {
|
|
856
|
+
const result = inputRegistry.get(regInputName);
|
|
857
|
+
if (result) return result;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
716
860
|
if (memberAst._tag === "Transformation") {
|
|
717
861
|
const toAst = memberAst.to;
|
|
718
862
|
const transformedInputName = cache?.astToInputName?.get(toAst);
|
|
@@ -720,6 +864,54 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
720
864
|
const result = inputRegistry.get(transformedInputName);
|
|
721
865
|
if (result) return result;
|
|
722
866
|
}
|
|
867
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
868
|
+
if (inputReg.schema.ast === toAst) {
|
|
869
|
+
const result = inputRegistry.get(regInputName);
|
|
870
|
+
if (result) return result;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
875
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
876
|
+
(p) => String(p.name) === "value"
|
|
877
|
+
);
|
|
878
|
+
if (valueField) {
|
|
879
|
+
const valueType = valueField.type;
|
|
880
|
+
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
881
|
+
if (valueInputName) {
|
|
882
|
+
const result = inputRegistry.get(valueInputName);
|
|
883
|
+
if (result) return result;
|
|
884
|
+
}
|
|
885
|
+
for (const [regInputName, inputReg] of inputs) {
|
|
886
|
+
if (inputReg.schema.ast === valueType) {
|
|
887
|
+
const result = inputRegistry.get(regInputName);
|
|
888
|
+
if (result) return result;
|
|
889
|
+
}
|
|
890
|
+
let regAst = inputReg.schema.ast;
|
|
891
|
+
while (regAst._tag === "Transformation") {
|
|
892
|
+
regAst = regAst.to;
|
|
893
|
+
if (regAst === valueType) {
|
|
894
|
+
const result = inputRegistry.get(regInputName);
|
|
895
|
+
if (result) return result;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
899
|
+
const result = inputRegistry.get(regInputName);
|
|
900
|
+
if (result) return result;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
904
|
+
S2.make(valueType),
|
|
905
|
+
enumRegistry,
|
|
906
|
+
inputRegistry,
|
|
907
|
+
inputs,
|
|
908
|
+
enums,
|
|
909
|
+
cache
|
|
910
|
+
);
|
|
911
|
+
if (innerResult) {
|
|
912
|
+
return innerResult;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
723
915
|
}
|
|
724
916
|
}
|
|
725
917
|
const allLiterals = unionAst.types.every((t) => t._tag === "Literal");
|
|
@@ -754,7 +946,7 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
754
946
|
if (ast._tag === "Suspend") {
|
|
755
947
|
const innerAst = ast.f();
|
|
756
948
|
return toGraphQLInputTypeWithRegistry(
|
|
757
|
-
|
|
949
|
+
S2.make(innerAst),
|
|
758
950
|
enumRegistry,
|
|
759
951
|
inputRegistry,
|
|
760
952
|
inputs,
|
|
@@ -771,7 +963,7 @@ function toGraphQLArgsWithRegistry(schema, enumRegistry, inputRegistry, inputs,
|
|
|
771
963
|
for (const field2 of ast.propertySignatures) {
|
|
772
964
|
const fieldName = String(field2.name);
|
|
773
965
|
if (fieldName === "_tag") continue;
|
|
774
|
-
const fieldSchema =
|
|
966
|
+
const fieldSchema = S2.make(field2.type);
|
|
775
967
|
let fieldType = toGraphQLInputTypeWithRegistry(
|
|
776
968
|
fieldSchema,
|
|
777
969
|
enumRegistry,
|
|
@@ -808,7 +1000,7 @@ function isOptionSchema(schema) {
|
|
|
808
1000
|
}
|
|
809
1001
|
function encodeResolverOutput(schema, value) {
|
|
810
1002
|
if (isOptionSchema(schema)) {
|
|
811
|
-
return Effect.orDie(
|
|
1003
|
+
return Effect.orDie(S2.encode(schema)(value));
|
|
812
1004
|
}
|
|
813
1005
|
return Effect.succeed(value);
|
|
814
1006
|
}
|