@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/builder/index.js
CHANGED
|
@@ -395,6 +395,12 @@ function handleTransformationAST(ast, ctx) {
|
|
|
395
395
|
const result = ctx.typeRegistry.get(typeName);
|
|
396
396
|
if (result) return result;
|
|
397
397
|
}
|
|
398
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
399
|
+
if (typeReg.schema.ast === memberAst) {
|
|
400
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
401
|
+
if (result) return result;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
398
404
|
if (memberAst._tag === "Transformation") {
|
|
399
405
|
const innerToAst = memberAst.to;
|
|
400
406
|
const transformedTypeName = ctx.astToTypeName?.get(innerToAst);
|
|
@@ -402,6 +408,41 @@ function handleTransformationAST(ast, ctx) {
|
|
|
402
408
|
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
403
409
|
if (result) return result;
|
|
404
410
|
}
|
|
411
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
412
|
+
if (typeReg.schema.ast === innerToAst) {
|
|
413
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
414
|
+
if (result) return result;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
if (memberAst._tag === "TypeLiteral") {
|
|
419
|
+
const valueField = memberAst.propertySignatures?.find(
|
|
420
|
+
(p) => String(p.name) === "value"
|
|
421
|
+
);
|
|
422
|
+
if (valueField) {
|
|
423
|
+
const valueType = valueField.type;
|
|
424
|
+
const valueTypeName = ctx.astToTypeName?.get(valueType);
|
|
425
|
+
if (valueTypeName) {
|
|
426
|
+
const result = ctx.typeRegistry.get(valueTypeName);
|
|
427
|
+
if (result) return result;
|
|
428
|
+
}
|
|
429
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
430
|
+
if (typeReg.schema.ast === valueType) {
|
|
431
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
432
|
+
if (result) return result;
|
|
433
|
+
}
|
|
434
|
+
let regAst = typeReg.schema.ast;
|
|
435
|
+
while (regAst._tag === "Transformation") {
|
|
436
|
+
regAst = regAst.to;
|
|
437
|
+
if (regAst === valueType) {
|
|
438
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
439
|
+
if (result) return result;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
const innerResult = toGraphQLTypeWithRegistry(S2.make(valueType), ctx);
|
|
444
|
+
if (innerResult) return innerResult;
|
|
445
|
+
}
|
|
405
446
|
}
|
|
406
447
|
}
|
|
407
448
|
}
|
|
@@ -438,6 +479,12 @@ function handleUnionAST(ast, ctx) {
|
|
|
438
479
|
const result = ctx.typeRegistry.get(typeName);
|
|
439
480
|
if (result) return result;
|
|
440
481
|
}
|
|
482
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
483
|
+
if (typeReg.schema.ast === memberAst) {
|
|
484
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
485
|
+
if (result) return result;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
441
488
|
if (memberAst._tag === "Transformation") {
|
|
442
489
|
const toAst = memberAst.to;
|
|
443
490
|
const transformedTypeName = ctx.astToTypeName?.get(toAst);
|
|
@@ -445,13 +492,39 @@ function handleUnionAST(ast, ctx) {
|
|
|
445
492
|
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
446
493
|
if (result) return result;
|
|
447
494
|
}
|
|
495
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
496
|
+
if (typeReg.schema.ast === toAst) {
|
|
497
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
498
|
+
if (result) return result;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
448
501
|
}
|
|
449
502
|
if (memberAst._tag === "TypeLiteral") {
|
|
450
503
|
const valueField = memberAst.propertySignatures?.find(
|
|
451
504
|
(p) => String(p.name) === "value"
|
|
452
505
|
);
|
|
453
506
|
if (valueField) {
|
|
454
|
-
const
|
|
507
|
+
const valueType = valueField.type;
|
|
508
|
+
const valueTypeName = ctx.astToTypeName?.get(valueType);
|
|
509
|
+
if (valueTypeName) {
|
|
510
|
+
const result = ctx.typeRegistry.get(valueTypeName);
|
|
511
|
+
if (result) return result;
|
|
512
|
+
}
|
|
513
|
+
for (const [regTypeName, typeReg] of ctx.types) {
|
|
514
|
+
if (typeReg.schema.ast === valueType) {
|
|
515
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
516
|
+
if (result) return result;
|
|
517
|
+
}
|
|
518
|
+
let regAst = typeReg.schema.ast;
|
|
519
|
+
while (regAst._tag === "Transformation") {
|
|
520
|
+
regAst = regAst.to;
|
|
521
|
+
if (regAst === valueType) {
|
|
522
|
+
const result = ctx.typeRegistry.get(regTypeName);
|
|
523
|
+
if (result) return result;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
const innerResult = toGraphQLTypeWithRegistry(S2.make(valueType), ctx);
|
|
455
528
|
if (innerResult) {
|
|
456
529
|
return innerResult;
|
|
457
530
|
}
|
|
@@ -627,15 +700,57 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
627
700
|
if (memberAst._tag === "UndefinedKeyword") continue;
|
|
628
701
|
const inputName = cache?.astToInputName?.get(memberAst);
|
|
629
702
|
if (inputName) {
|
|
630
|
-
const
|
|
631
|
-
if (
|
|
703
|
+
const inputReg = inputs.get(inputName);
|
|
704
|
+
if (inputReg) {
|
|
705
|
+
return toGraphQLInputTypeWithRegistry(
|
|
706
|
+
inputReg.schema,
|
|
707
|
+
enumRegistry,
|
|
708
|
+
inputRegistry,
|
|
709
|
+
inputs,
|
|
710
|
+
enums,
|
|
711
|
+
cache
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
for (const [, inputReg] of inputs) {
|
|
716
|
+
if (inputReg.schema.ast === memberAst) {
|
|
717
|
+
return toGraphQLInputTypeWithRegistry(
|
|
718
|
+
inputReg.schema,
|
|
719
|
+
enumRegistry,
|
|
720
|
+
inputRegistry,
|
|
721
|
+
inputs,
|
|
722
|
+
enums,
|
|
723
|
+
cache
|
|
724
|
+
);
|
|
725
|
+
}
|
|
632
726
|
}
|
|
633
727
|
if (memberAst._tag === "Transformation") {
|
|
634
728
|
const innerToAst = memberAst.to;
|
|
635
729
|
const transformedInputName = cache?.astToInputName?.get(innerToAst);
|
|
636
730
|
if (transformedInputName) {
|
|
637
|
-
const
|
|
638
|
-
if (
|
|
731
|
+
const inputReg = inputs.get(transformedInputName);
|
|
732
|
+
if (inputReg) {
|
|
733
|
+
return toGraphQLInputTypeWithRegistry(
|
|
734
|
+
inputReg.schema,
|
|
735
|
+
enumRegistry,
|
|
736
|
+
inputRegistry,
|
|
737
|
+
inputs,
|
|
738
|
+
enums,
|
|
739
|
+
cache
|
|
740
|
+
);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
for (const [, inputReg] of inputs) {
|
|
744
|
+
if (inputReg.schema.ast === innerToAst) {
|
|
745
|
+
return toGraphQLInputTypeWithRegistry(
|
|
746
|
+
inputReg.schema,
|
|
747
|
+
enumRegistry,
|
|
748
|
+
inputRegistry,
|
|
749
|
+
inputs,
|
|
750
|
+
enums,
|
|
751
|
+
cache
|
|
752
|
+
);
|
|
753
|
+
}
|
|
639
754
|
}
|
|
640
755
|
}
|
|
641
756
|
if (memberAst._tag === "TypeLiteral") {
|
|
@@ -643,8 +758,59 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
643
758
|
(p) => String(p.name) === "value"
|
|
644
759
|
);
|
|
645
760
|
if (valueField) {
|
|
761
|
+
const valueType = valueField.type;
|
|
762
|
+
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
763
|
+
if (valueInputName) {
|
|
764
|
+
const inputReg = inputs.get(valueInputName);
|
|
765
|
+
if (inputReg) {
|
|
766
|
+
return toGraphQLInputTypeWithRegistry(
|
|
767
|
+
inputReg.schema,
|
|
768
|
+
enumRegistry,
|
|
769
|
+
inputRegistry,
|
|
770
|
+
inputs,
|
|
771
|
+
enums,
|
|
772
|
+
cache
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
for (const [, inputReg] of inputs) {
|
|
777
|
+
if (inputReg.schema.ast === valueType) {
|
|
778
|
+
return toGraphQLInputTypeWithRegistry(
|
|
779
|
+
inputReg.schema,
|
|
780
|
+
enumRegistry,
|
|
781
|
+
inputRegistry,
|
|
782
|
+
inputs,
|
|
783
|
+
enums,
|
|
784
|
+
cache
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
let regAst = inputReg.schema.ast;
|
|
788
|
+
while (regAst._tag === "Transformation") {
|
|
789
|
+
regAst = regAst.to;
|
|
790
|
+
if (regAst === valueType) {
|
|
791
|
+
return toGraphQLInputTypeWithRegistry(
|
|
792
|
+
inputReg.schema,
|
|
793
|
+
enumRegistry,
|
|
794
|
+
inputRegistry,
|
|
795
|
+
inputs,
|
|
796
|
+
enums,
|
|
797
|
+
cache
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
802
|
+
return toGraphQLInputTypeWithRegistry(
|
|
803
|
+
inputReg.schema,
|
|
804
|
+
enumRegistry,
|
|
805
|
+
inputRegistry,
|
|
806
|
+
inputs,
|
|
807
|
+
enums,
|
|
808
|
+
cache
|
|
809
|
+
);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
646
812
|
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
647
|
-
S2.make(
|
|
813
|
+
S2.make(valueType),
|
|
648
814
|
enumRegistry,
|
|
649
815
|
inputRegistry,
|
|
650
816
|
inputs,
|
|
@@ -693,15 +859,57 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
693
859
|
for (const memberAst of unionAst.types) {
|
|
694
860
|
const inputName = cache?.astToInputName?.get(memberAst);
|
|
695
861
|
if (inputName) {
|
|
696
|
-
const
|
|
697
|
-
if (
|
|
862
|
+
const inputReg = inputs.get(inputName);
|
|
863
|
+
if (inputReg) {
|
|
864
|
+
return toGraphQLInputTypeWithRegistry(
|
|
865
|
+
inputReg.schema,
|
|
866
|
+
enumRegistry,
|
|
867
|
+
inputRegistry,
|
|
868
|
+
inputs,
|
|
869
|
+
enums,
|
|
870
|
+
cache
|
|
871
|
+
);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
for (const [, inputReg] of inputs) {
|
|
875
|
+
if (inputReg.schema.ast === memberAst) {
|
|
876
|
+
return toGraphQLInputTypeWithRegistry(
|
|
877
|
+
inputReg.schema,
|
|
878
|
+
enumRegistry,
|
|
879
|
+
inputRegistry,
|
|
880
|
+
inputs,
|
|
881
|
+
enums,
|
|
882
|
+
cache
|
|
883
|
+
);
|
|
884
|
+
}
|
|
698
885
|
}
|
|
699
886
|
if (memberAst._tag === "Transformation") {
|
|
700
887
|
const toAst = memberAst.to;
|
|
701
888
|
const transformedInputName = cache?.astToInputName?.get(toAst);
|
|
702
889
|
if (transformedInputName) {
|
|
703
|
-
const
|
|
704
|
-
if (
|
|
890
|
+
const inputReg = inputs.get(transformedInputName);
|
|
891
|
+
if (inputReg) {
|
|
892
|
+
return toGraphQLInputTypeWithRegistry(
|
|
893
|
+
inputReg.schema,
|
|
894
|
+
enumRegistry,
|
|
895
|
+
inputRegistry,
|
|
896
|
+
inputs,
|
|
897
|
+
enums,
|
|
898
|
+
cache
|
|
899
|
+
);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
for (const [, inputReg] of inputs) {
|
|
903
|
+
if (inputReg.schema.ast === toAst) {
|
|
904
|
+
return toGraphQLInputTypeWithRegistry(
|
|
905
|
+
inputReg.schema,
|
|
906
|
+
enumRegistry,
|
|
907
|
+
inputRegistry,
|
|
908
|
+
inputs,
|
|
909
|
+
enums,
|
|
910
|
+
cache
|
|
911
|
+
);
|
|
912
|
+
}
|
|
705
913
|
}
|
|
706
914
|
}
|
|
707
915
|
if (memberAst._tag === "TypeLiteral") {
|
|
@@ -709,8 +917,59 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
709
917
|
(p) => String(p.name) === "value"
|
|
710
918
|
);
|
|
711
919
|
if (valueField) {
|
|
920
|
+
const valueType = valueField.type;
|
|
921
|
+
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
922
|
+
if (valueInputName) {
|
|
923
|
+
const inputReg = inputs.get(valueInputName);
|
|
924
|
+
if (inputReg) {
|
|
925
|
+
return toGraphQLInputTypeWithRegistry(
|
|
926
|
+
inputReg.schema,
|
|
927
|
+
enumRegistry,
|
|
928
|
+
inputRegistry,
|
|
929
|
+
inputs,
|
|
930
|
+
enums,
|
|
931
|
+
cache
|
|
932
|
+
);
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
for (const [, inputReg] of inputs) {
|
|
936
|
+
if (inputReg.schema.ast === valueType) {
|
|
937
|
+
return toGraphQLInputTypeWithRegistry(
|
|
938
|
+
inputReg.schema,
|
|
939
|
+
enumRegistry,
|
|
940
|
+
inputRegistry,
|
|
941
|
+
inputs,
|
|
942
|
+
enums,
|
|
943
|
+
cache
|
|
944
|
+
);
|
|
945
|
+
}
|
|
946
|
+
let regAst = inputReg.schema.ast;
|
|
947
|
+
while (regAst._tag === "Transformation") {
|
|
948
|
+
regAst = regAst.to;
|
|
949
|
+
if (regAst === valueType) {
|
|
950
|
+
return toGraphQLInputTypeWithRegistry(
|
|
951
|
+
inputReg.schema,
|
|
952
|
+
enumRegistry,
|
|
953
|
+
inputRegistry,
|
|
954
|
+
inputs,
|
|
955
|
+
enums,
|
|
956
|
+
cache
|
|
957
|
+
);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
961
|
+
return toGraphQLInputTypeWithRegistry(
|
|
962
|
+
inputReg.schema,
|
|
963
|
+
enumRegistry,
|
|
964
|
+
inputRegistry,
|
|
965
|
+
inputs,
|
|
966
|
+
enums,
|
|
967
|
+
cache
|
|
968
|
+
);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
712
971
|
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
713
|
-
S2.make(
|
|
972
|
+
S2.make(valueType),
|
|
714
973
|
enumRegistry,
|
|
715
974
|
inputRegistry,
|
|
716
975
|
inputs,
|