@effect-gql/core 1.4.1 → 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 +70 -0
- package/builder/index.cjs.map +1 -1
- package/builder/index.js +70 -0
- package/builder/index.js.map +1 -1
- package/index.cjs +70 -0
- package/index.cjs.map +1 -1
- package/index.js +70 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -406,7 +406,27 @@ function getOptionInnerType2(ast) {
|
|
|
406
406
|
}
|
|
407
407
|
function handleTransformationAST(ast, ctx) {
|
|
408
408
|
const toAst = ast.to;
|
|
409
|
+
const fromAst = ast.from;
|
|
409
410
|
if (isOptionDeclaration2(toAst)) {
|
|
411
|
+
if (fromAst && fromAst._tag === "Union") {
|
|
412
|
+
for (const memberAst of fromAst.types) {
|
|
413
|
+
if (memberAst._tag === "Literal") continue;
|
|
414
|
+
if (memberAst._tag === "UndefinedKeyword") continue;
|
|
415
|
+
const typeName = ctx.astToTypeName?.get(memberAst);
|
|
416
|
+
if (typeName) {
|
|
417
|
+
const result = ctx.typeRegistry.get(typeName);
|
|
418
|
+
if (result) return result;
|
|
419
|
+
}
|
|
420
|
+
if (memberAst._tag === "Transformation") {
|
|
421
|
+
const innerToAst = memberAst.to;
|
|
422
|
+
const transformedTypeName = ctx.astToTypeName?.get(innerToAst);
|
|
423
|
+
if (transformedTypeName) {
|
|
424
|
+
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
425
|
+
if (result) return result;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
410
430
|
const innerType = getOptionInnerType2(toAst);
|
|
411
431
|
if (innerType) {
|
|
412
432
|
return toGraphQLTypeWithRegistry(S.make(innerType), ctx);
|
|
@@ -434,6 +454,21 @@ function handleUnionAST(ast, ctx) {
|
|
|
434
454
|
const unionType2 = findRegisteredUnion(ast.types, ctx);
|
|
435
455
|
if (unionType2) return unionType2;
|
|
436
456
|
}
|
|
457
|
+
for (const memberAst of ast.types) {
|
|
458
|
+
const typeName = ctx.astToTypeName?.get(memberAst);
|
|
459
|
+
if (typeName) {
|
|
460
|
+
const result = ctx.typeRegistry.get(typeName);
|
|
461
|
+
if (result) return result;
|
|
462
|
+
}
|
|
463
|
+
if (memberAst._tag === "Transformation") {
|
|
464
|
+
const toAst = memberAst.to;
|
|
465
|
+
const transformedTypeName = ctx.astToTypeName?.get(toAst);
|
|
466
|
+
if (transformedTypeName) {
|
|
467
|
+
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
468
|
+
if (result) return result;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
437
472
|
if (ast.types.length > 0) {
|
|
438
473
|
return toGraphQLTypeWithRegistry(S.make(ast.types[0]), ctx);
|
|
439
474
|
}
|
|
@@ -588,6 +623,26 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
588
623
|
}
|
|
589
624
|
if (ast._tag === "Transformation") {
|
|
590
625
|
const toAst = ast.to;
|
|
626
|
+
const fromAst = ast.from;
|
|
627
|
+
if (isOptionDeclaration2(toAst) && fromAst && fromAst._tag === "Union") {
|
|
628
|
+
for (const memberAst of fromAst.types) {
|
|
629
|
+
if (memberAst._tag === "Literal") continue;
|
|
630
|
+
if (memberAst._tag === "UndefinedKeyword") continue;
|
|
631
|
+
const inputName = cache?.astToInputName?.get(memberAst);
|
|
632
|
+
if (inputName) {
|
|
633
|
+
const result = inputRegistry.get(inputName);
|
|
634
|
+
if (result) return result;
|
|
635
|
+
}
|
|
636
|
+
if (memberAst._tag === "Transformation") {
|
|
637
|
+
const innerToAst = memberAst.to;
|
|
638
|
+
const transformedInputName = cache?.astToInputName?.get(innerToAst);
|
|
639
|
+
if (transformedInputName) {
|
|
640
|
+
const result = inputRegistry.get(transformedInputName);
|
|
641
|
+
if (result) return result;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
591
646
|
return toGraphQLInputTypeWithRegistry(
|
|
592
647
|
S.make(toAst),
|
|
593
648
|
enumRegistry,
|
|
@@ -620,6 +675,21 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
620
675
|
cache
|
|
621
676
|
);
|
|
622
677
|
}
|
|
678
|
+
for (const memberAst of unionAst.types) {
|
|
679
|
+
const inputName = cache?.astToInputName?.get(memberAst);
|
|
680
|
+
if (inputName) {
|
|
681
|
+
const result = inputRegistry.get(inputName);
|
|
682
|
+
if (result) return result;
|
|
683
|
+
}
|
|
684
|
+
if (memberAst._tag === "Transformation") {
|
|
685
|
+
const toAst = memberAst.to;
|
|
686
|
+
const transformedInputName = cache?.astToInputName?.get(toAst);
|
|
687
|
+
if (transformedInputName) {
|
|
688
|
+
const result = inputRegistry.get(transformedInputName);
|
|
689
|
+
if (result) return result;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
623
693
|
const allLiterals = unionAst.types.every((t) => t._tag === "Literal");
|
|
624
694
|
if (allLiterals) {
|
|
625
695
|
const literalValues = unionAst.types.map((t) => String(t.literal)).sort();
|