@effect-gql/core 1.4.4 → 1.4.6
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 +270 -11
- package/builder/index.cjs.map +1 -1
- package/builder/index.js +270 -11
- package/builder/index.js.map +1 -1
- package/index.cjs +270 -11
- package/index.cjs.map +1 -1
- package/index.js +270 -11
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -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,6 +454,41 @@ 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
|
}
|
|
@@ -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,13 +538,39 @@ 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
|
+
}
|
|
494
547
|
}
|
|
495
548
|
if (memberAst._tag === "TypeLiteral") {
|
|
496
549
|
const valueField = memberAst.propertySignatures?.find(
|
|
497
550
|
(p) => String(p.name) === "value"
|
|
498
551
|
);
|
|
499
552
|
if (valueField) {
|
|
500
|
-
const
|
|
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);
|
|
501
574
|
if (innerResult) {
|
|
502
575
|
return innerResult;
|
|
503
576
|
}
|
|
@@ -673,15 +746,57 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
673
746
|
if (memberAst._tag === "UndefinedKeyword") continue;
|
|
674
747
|
const inputName = cache?.astToInputName?.get(memberAst);
|
|
675
748
|
if (inputName) {
|
|
676
|
-
const
|
|
677
|
-
if (
|
|
749
|
+
const inputReg = inputs.get(inputName);
|
|
750
|
+
if (inputReg) {
|
|
751
|
+
return toGraphQLInputTypeWithRegistry(
|
|
752
|
+
inputReg.schema,
|
|
753
|
+
enumRegistry,
|
|
754
|
+
inputRegistry,
|
|
755
|
+
inputs,
|
|
756
|
+
enums,
|
|
757
|
+
cache
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
for (const [, inputReg] of inputs) {
|
|
762
|
+
if (inputReg.schema.ast === memberAst) {
|
|
763
|
+
return toGraphQLInputTypeWithRegistry(
|
|
764
|
+
inputReg.schema,
|
|
765
|
+
enumRegistry,
|
|
766
|
+
inputRegistry,
|
|
767
|
+
inputs,
|
|
768
|
+
enums,
|
|
769
|
+
cache
|
|
770
|
+
);
|
|
771
|
+
}
|
|
678
772
|
}
|
|
679
773
|
if (memberAst._tag === "Transformation") {
|
|
680
774
|
const innerToAst = memberAst.to;
|
|
681
775
|
const transformedInputName = cache?.astToInputName?.get(innerToAst);
|
|
682
776
|
if (transformedInputName) {
|
|
683
|
-
const
|
|
684
|
-
if (
|
|
777
|
+
const inputReg = inputs.get(transformedInputName);
|
|
778
|
+
if (inputReg) {
|
|
779
|
+
return toGraphQLInputTypeWithRegistry(
|
|
780
|
+
inputReg.schema,
|
|
781
|
+
enumRegistry,
|
|
782
|
+
inputRegistry,
|
|
783
|
+
inputs,
|
|
784
|
+
enums,
|
|
785
|
+
cache
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
for (const [, inputReg] of inputs) {
|
|
790
|
+
if (inputReg.schema.ast === innerToAst) {
|
|
791
|
+
return toGraphQLInputTypeWithRegistry(
|
|
792
|
+
inputReg.schema,
|
|
793
|
+
enumRegistry,
|
|
794
|
+
inputRegistry,
|
|
795
|
+
inputs,
|
|
796
|
+
enums,
|
|
797
|
+
cache
|
|
798
|
+
);
|
|
799
|
+
}
|
|
685
800
|
}
|
|
686
801
|
}
|
|
687
802
|
if (memberAst._tag === "TypeLiteral") {
|
|
@@ -689,8 +804,59 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
689
804
|
(p) => String(p.name) === "value"
|
|
690
805
|
);
|
|
691
806
|
if (valueField) {
|
|
807
|
+
const valueType = valueField.type;
|
|
808
|
+
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
809
|
+
if (valueInputName) {
|
|
810
|
+
const inputReg = inputs.get(valueInputName);
|
|
811
|
+
if (inputReg) {
|
|
812
|
+
return toGraphQLInputTypeWithRegistry(
|
|
813
|
+
inputReg.schema,
|
|
814
|
+
enumRegistry,
|
|
815
|
+
inputRegistry,
|
|
816
|
+
inputs,
|
|
817
|
+
enums,
|
|
818
|
+
cache
|
|
819
|
+
);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
for (const [, inputReg] of inputs) {
|
|
823
|
+
if (inputReg.schema.ast === valueType) {
|
|
824
|
+
return toGraphQLInputTypeWithRegistry(
|
|
825
|
+
inputReg.schema,
|
|
826
|
+
enumRegistry,
|
|
827
|
+
inputRegistry,
|
|
828
|
+
inputs,
|
|
829
|
+
enums,
|
|
830
|
+
cache
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
let regAst = inputReg.schema.ast;
|
|
834
|
+
while (regAst._tag === "Transformation") {
|
|
835
|
+
regAst = regAst.to;
|
|
836
|
+
if (regAst === valueType) {
|
|
837
|
+
return toGraphQLInputTypeWithRegistry(
|
|
838
|
+
inputReg.schema,
|
|
839
|
+
enumRegistry,
|
|
840
|
+
inputRegistry,
|
|
841
|
+
inputs,
|
|
842
|
+
enums,
|
|
843
|
+
cache
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
848
|
+
return toGraphQLInputTypeWithRegistry(
|
|
849
|
+
inputReg.schema,
|
|
850
|
+
enumRegistry,
|
|
851
|
+
inputRegistry,
|
|
852
|
+
inputs,
|
|
853
|
+
enums,
|
|
854
|
+
cache
|
|
855
|
+
);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
692
858
|
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
693
|
-
S2.make(
|
|
859
|
+
S2.make(valueType),
|
|
694
860
|
enumRegistry,
|
|
695
861
|
inputRegistry,
|
|
696
862
|
inputs,
|
|
@@ -739,15 +905,57 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
739
905
|
for (const memberAst of unionAst.types) {
|
|
740
906
|
const inputName = cache?.astToInputName?.get(memberAst);
|
|
741
907
|
if (inputName) {
|
|
742
|
-
const
|
|
743
|
-
if (
|
|
908
|
+
const inputReg = inputs.get(inputName);
|
|
909
|
+
if (inputReg) {
|
|
910
|
+
return toGraphQLInputTypeWithRegistry(
|
|
911
|
+
inputReg.schema,
|
|
912
|
+
enumRegistry,
|
|
913
|
+
inputRegistry,
|
|
914
|
+
inputs,
|
|
915
|
+
enums,
|
|
916
|
+
cache
|
|
917
|
+
);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
for (const [, inputReg] of inputs) {
|
|
921
|
+
if (inputReg.schema.ast === memberAst) {
|
|
922
|
+
return toGraphQLInputTypeWithRegistry(
|
|
923
|
+
inputReg.schema,
|
|
924
|
+
enumRegistry,
|
|
925
|
+
inputRegistry,
|
|
926
|
+
inputs,
|
|
927
|
+
enums,
|
|
928
|
+
cache
|
|
929
|
+
);
|
|
930
|
+
}
|
|
744
931
|
}
|
|
745
932
|
if (memberAst._tag === "Transformation") {
|
|
746
933
|
const toAst = memberAst.to;
|
|
747
934
|
const transformedInputName = cache?.astToInputName?.get(toAst);
|
|
748
935
|
if (transformedInputName) {
|
|
749
|
-
const
|
|
750
|
-
if (
|
|
936
|
+
const inputReg = inputs.get(transformedInputName);
|
|
937
|
+
if (inputReg) {
|
|
938
|
+
return toGraphQLInputTypeWithRegistry(
|
|
939
|
+
inputReg.schema,
|
|
940
|
+
enumRegistry,
|
|
941
|
+
inputRegistry,
|
|
942
|
+
inputs,
|
|
943
|
+
enums,
|
|
944
|
+
cache
|
|
945
|
+
);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
for (const [, inputReg] of inputs) {
|
|
949
|
+
if (inputReg.schema.ast === toAst) {
|
|
950
|
+
return toGraphQLInputTypeWithRegistry(
|
|
951
|
+
inputReg.schema,
|
|
952
|
+
enumRegistry,
|
|
953
|
+
inputRegistry,
|
|
954
|
+
inputs,
|
|
955
|
+
enums,
|
|
956
|
+
cache
|
|
957
|
+
);
|
|
958
|
+
}
|
|
751
959
|
}
|
|
752
960
|
}
|
|
753
961
|
if (memberAst._tag === "TypeLiteral") {
|
|
@@ -755,8 +963,59 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
755
963
|
(p) => String(p.name) === "value"
|
|
756
964
|
);
|
|
757
965
|
if (valueField) {
|
|
966
|
+
const valueType = valueField.type;
|
|
967
|
+
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
968
|
+
if (valueInputName) {
|
|
969
|
+
const inputReg = inputs.get(valueInputName);
|
|
970
|
+
if (inputReg) {
|
|
971
|
+
return toGraphQLInputTypeWithRegistry(
|
|
972
|
+
inputReg.schema,
|
|
973
|
+
enumRegistry,
|
|
974
|
+
inputRegistry,
|
|
975
|
+
inputs,
|
|
976
|
+
enums,
|
|
977
|
+
cache
|
|
978
|
+
);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
for (const [, inputReg] of inputs) {
|
|
982
|
+
if (inputReg.schema.ast === valueType) {
|
|
983
|
+
return toGraphQLInputTypeWithRegistry(
|
|
984
|
+
inputReg.schema,
|
|
985
|
+
enumRegistry,
|
|
986
|
+
inputRegistry,
|
|
987
|
+
inputs,
|
|
988
|
+
enums,
|
|
989
|
+
cache
|
|
990
|
+
);
|
|
991
|
+
}
|
|
992
|
+
let regAst = inputReg.schema.ast;
|
|
993
|
+
while (regAst._tag === "Transformation") {
|
|
994
|
+
regAst = regAst.to;
|
|
995
|
+
if (regAst === valueType) {
|
|
996
|
+
return toGraphQLInputTypeWithRegistry(
|
|
997
|
+
inputReg.schema,
|
|
998
|
+
enumRegistry,
|
|
999
|
+
inputRegistry,
|
|
1000
|
+
inputs,
|
|
1001
|
+
enums,
|
|
1002
|
+
cache
|
|
1003
|
+
);
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
1007
|
+
return toGraphQLInputTypeWithRegistry(
|
|
1008
|
+
inputReg.schema,
|
|
1009
|
+
enumRegistry,
|
|
1010
|
+
inputRegistry,
|
|
1011
|
+
inputs,
|
|
1012
|
+
enums,
|
|
1013
|
+
cache
|
|
1014
|
+
);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
758
1017
|
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
759
|
-
S2.make(
|
|
1018
|
+
S2.make(valueType),
|
|
760
1019
|
enumRegistry,
|
|
761
1020
|
inputRegistry,
|
|
762
1021
|
inputs,
|