@effect-gql/core 1.4.0 → 1.4.2
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 +99 -14
- package/builder/index.cjs.map +1 -1
- package/builder/index.js +99 -14
- package/builder/index.js.map +1 -1
- package/index.cjs +100 -14
- package/index.cjs.map +1 -1
- package/index.js +100 -14
- package/index.js.map +1 -1
- package/package.json +1 -1
package/builder/index.cjs
CHANGED
|
@@ -98,6 +98,7 @@ var toGraphQLType = (schema) => {
|
|
|
98
98
|
const fields = {};
|
|
99
99
|
for (const field2 of ast.propertySignatures) {
|
|
100
100
|
const fieldName = String(field2.name);
|
|
101
|
+
if (fieldName === "_tag") continue;
|
|
101
102
|
const fieldSchema = S__namespace.make(field2.type);
|
|
102
103
|
let fieldType = toGraphQLType(fieldSchema);
|
|
103
104
|
if (!field2.isOptional) {
|
|
@@ -173,6 +174,7 @@ var toGraphQLInputType = (schema) => {
|
|
|
173
174
|
const fields = {};
|
|
174
175
|
for (const field2 of ast.propertySignatures) {
|
|
175
176
|
const fieldName = String(field2.name);
|
|
177
|
+
if (fieldName === "_tag") continue;
|
|
176
178
|
const fieldSchema = S__namespace.make(field2.type);
|
|
177
179
|
let fieldType = toGraphQLInputType(fieldSchema);
|
|
178
180
|
if (!field2.isOptional) {
|
|
@@ -223,6 +225,7 @@ var toGraphQLArgs = (schema) => {
|
|
|
223
225
|
const args = {};
|
|
224
226
|
for (const field2 of ast.propertySignatures) {
|
|
225
227
|
const fieldName = String(field2.name);
|
|
228
|
+
if (fieldName === "_tag") continue;
|
|
226
229
|
const fieldSchema = S__namespace.make(field2.type);
|
|
227
230
|
let fieldType = toGraphQLInputType(fieldSchema);
|
|
228
231
|
if (!field2.isOptional) {
|
|
@@ -379,7 +382,27 @@ function getOptionInnerType2(ast) {
|
|
|
379
382
|
}
|
|
380
383
|
function handleTransformationAST(ast, ctx) {
|
|
381
384
|
const toAst = ast.to;
|
|
385
|
+
const fromAst = ast.from;
|
|
382
386
|
if (isOptionDeclaration2(toAst)) {
|
|
387
|
+
if (fromAst && fromAst._tag === "Union") {
|
|
388
|
+
for (const memberAst of fromAst.types) {
|
|
389
|
+
if (memberAst._tag === "Literal") continue;
|
|
390
|
+
if (memberAst._tag === "UndefinedKeyword") continue;
|
|
391
|
+
const typeName = ctx.astToTypeName?.get(memberAst);
|
|
392
|
+
if (typeName) {
|
|
393
|
+
const result = ctx.typeRegistry.get(typeName);
|
|
394
|
+
if (result) return result;
|
|
395
|
+
}
|
|
396
|
+
if (memberAst._tag === "Transformation") {
|
|
397
|
+
const innerToAst = memberAst.to;
|
|
398
|
+
const transformedTypeName = ctx.astToTypeName?.get(innerToAst);
|
|
399
|
+
if (transformedTypeName) {
|
|
400
|
+
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
401
|
+
if (result) return result;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
383
406
|
const innerType = getOptionInnerType2(toAst);
|
|
384
407
|
if (innerType) {
|
|
385
408
|
return toGraphQLTypeWithRegistry(S__namespace.make(innerType), ctx);
|
|
@@ -407,6 +430,21 @@ function handleUnionAST(ast, ctx) {
|
|
|
407
430
|
const unionType2 = findRegisteredUnion(ast.types, ctx);
|
|
408
431
|
if (unionType2) return unionType2;
|
|
409
432
|
}
|
|
433
|
+
for (const memberAst of ast.types) {
|
|
434
|
+
const typeName = ctx.astToTypeName?.get(memberAst);
|
|
435
|
+
if (typeName) {
|
|
436
|
+
const result = ctx.typeRegistry.get(typeName);
|
|
437
|
+
if (result) return result;
|
|
438
|
+
}
|
|
439
|
+
if (memberAst._tag === "Transformation") {
|
|
440
|
+
const toAst = memberAst.to;
|
|
441
|
+
const transformedTypeName = ctx.astToTypeName?.get(toAst);
|
|
442
|
+
if (transformedTypeName) {
|
|
443
|
+
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
444
|
+
if (result) return result;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
410
448
|
if (ast.types.length > 0) {
|
|
411
449
|
return toGraphQLTypeWithRegistry(S__namespace.make(ast.types[0]), ctx);
|
|
412
450
|
}
|
|
@@ -470,14 +508,21 @@ function schemaToFields(schema, ctx) {
|
|
|
470
508
|
}
|
|
471
509
|
if (ast._tag === "Declaration") {
|
|
472
510
|
const typeParams = ast.typeParameters;
|
|
473
|
-
if (typeParams && typeParams.length > 0
|
|
474
|
-
|
|
511
|
+
if (typeParams && typeParams.length > 0) {
|
|
512
|
+
let innerAst = typeParams[0];
|
|
513
|
+
while (innerAst._tag === "Transformation") {
|
|
514
|
+
innerAst = innerAst.to;
|
|
515
|
+
}
|
|
516
|
+
if (innerAst._tag === "TypeLiteral") {
|
|
517
|
+
ast = innerAst;
|
|
518
|
+
}
|
|
475
519
|
}
|
|
476
520
|
}
|
|
477
521
|
if (ast._tag === "TypeLiteral") {
|
|
478
522
|
const fields = {};
|
|
479
523
|
for (const field2 of ast.propertySignatures) {
|
|
480
524
|
const fieldName = String(field2.name);
|
|
525
|
+
if (fieldName === "_tag") continue;
|
|
481
526
|
const fieldSchema = S__namespace.make(field2.type);
|
|
482
527
|
let fieldType = toGraphQLTypeWithRegistry(fieldSchema, ctx);
|
|
483
528
|
if (!field2.isOptional) {
|
|
@@ -490,11 +535,15 @@ function schemaToFields(schema, ctx) {
|
|
|
490
535
|
return {};
|
|
491
536
|
}
|
|
492
537
|
function schemaToInputFields(schema, enumRegistry, inputRegistry, inputs, enums, cache) {
|
|
493
|
-
|
|
538
|
+
let ast = schema.ast;
|
|
539
|
+
while (ast._tag === "Transformation") {
|
|
540
|
+
ast = ast.to;
|
|
541
|
+
}
|
|
494
542
|
if (ast._tag === "TypeLiteral") {
|
|
495
543
|
const fields = {};
|
|
496
544
|
for (const field2 of ast.propertySignatures) {
|
|
497
545
|
const fieldName = String(field2.name);
|
|
546
|
+
if (fieldName === "_tag") continue;
|
|
498
547
|
const fieldSchema = S__namespace.make(field2.type);
|
|
499
548
|
let fieldType = toGraphQLInputTypeWithRegistry(
|
|
500
549
|
fieldSchema,
|
|
@@ -534,17 +583,6 @@ function buildInputTypeLookupCache(inputs, enums) {
|
|
|
534
583
|
}
|
|
535
584
|
function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inputs, enums, cache) {
|
|
536
585
|
const ast = schema.ast;
|
|
537
|
-
if (ast._tag === "Transformation") {
|
|
538
|
-
const toAst = ast.to;
|
|
539
|
-
return toGraphQLInputTypeWithRegistry(
|
|
540
|
-
S__namespace.make(toAst),
|
|
541
|
-
enumRegistry,
|
|
542
|
-
inputRegistry,
|
|
543
|
-
inputs,
|
|
544
|
-
enums,
|
|
545
|
-
cache
|
|
546
|
-
);
|
|
547
|
-
}
|
|
548
586
|
if (cache?.schemaToInputName || cache?.astToInputName) {
|
|
549
587
|
const inputName = cache.schemaToInputName?.get(schema) ?? cache.astToInputName?.get(ast);
|
|
550
588
|
if (inputName) {
|
|
@@ -559,6 +597,37 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
559
597
|
}
|
|
560
598
|
}
|
|
561
599
|
}
|
|
600
|
+
if (ast._tag === "Transformation") {
|
|
601
|
+
const toAst = ast.to;
|
|
602
|
+
const fromAst = ast.from;
|
|
603
|
+
if (isOptionDeclaration2(toAst) && fromAst && fromAst._tag === "Union") {
|
|
604
|
+
for (const memberAst of fromAst.types) {
|
|
605
|
+
if (memberAst._tag === "Literal") continue;
|
|
606
|
+
if (memberAst._tag === "UndefinedKeyword") continue;
|
|
607
|
+
const inputName = cache?.astToInputName?.get(memberAst);
|
|
608
|
+
if (inputName) {
|
|
609
|
+
const result = inputRegistry.get(inputName);
|
|
610
|
+
if (result) return result;
|
|
611
|
+
}
|
|
612
|
+
if (memberAst._tag === "Transformation") {
|
|
613
|
+
const innerToAst = memberAst.to;
|
|
614
|
+
const transformedInputName = cache?.astToInputName?.get(innerToAst);
|
|
615
|
+
if (transformedInputName) {
|
|
616
|
+
const result = inputRegistry.get(transformedInputName);
|
|
617
|
+
if (result) return result;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return toGraphQLInputTypeWithRegistry(
|
|
623
|
+
S__namespace.make(toAst),
|
|
624
|
+
enumRegistry,
|
|
625
|
+
inputRegistry,
|
|
626
|
+
inputs,
|
|
627
|
+
enums,
|
|
628
|
+
cache
|
|
629
|
+
);
|
|
630
|
+
}
|
|
562
631
|
if (ast._tag === "Union") {
|
|
563
632
|
const unionAst = ast;
|
|
564
633
|
const nonUndefinedTypes = unionAst.types.filter((t) => t._tag !== "UndefinedKeyword");
|
|
@@ -582,6 +651,21 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
582
651
|
cache
|
|
583
652
|
);
|
|
584
653
|
}
|
|
654
|
+
for (const memberAst of unionAst.types) {
|
|
655
|
+
const inputName = cache?.astToInputName?.get(memberAst);
|
|
656
|
+
if (inputName) {
|
|
657
|
+
const result = inputRegistry.get(inputName);
|
|
658
|
+
if (result) return result;
|
|
659
|
+
}
|
|
660
|
+
if (memberAst._tag === "Transformation") {
|
|
661
|
+
const toAst = memberAst.to;
|
|
662
|
+
const transformedInputName = cache?.astToInputName?.get(toAst);
|
|
663
|
+
if (transformedInputName) {
|
|
664
|
+
const result = inputRegistry.get(transformedInputName);
|
|
665
|
+
if (result) return result;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
585
669
|
const allLiterals = unionAst.types.every((t) => t._tag === "Literal");
|
|
586
670
|
if (allLiterals) {
|
|
587
671
|
const literalValues = unionAst.types.map((t) => String(t.literal)).sort();
|
|
@@ -630,6 +714,7 @@ function toGraphQLArgsWithRegistry(schema, enumRegistry, inputRegistry, inputs,
|
|
|
630
714
|
const args = {};
|
|
631
715
|
for (const field2 of ast.propertySignatures) {
|
|
632
716
|
const fieldName = String(field2.name);
|
|
717
|
+
if (fieldName === "_tag") continue;
|
|
633
718
|
const fieldSchema = S__namespace.make(field2.type);
|
|
634
719
|
let fieldType = toGraphQLInputTypeWithRegistry(
|
|
635
720
|
fieldSchema,
|