@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/index.cjs CHANGED
@@ -466,6 +466,12 @@ function handleTransformationAST(ast, ctx) {
466
466
  const result = ctx.typeRegistry.get(typeName);
467
467
  if (result) return result;
468
468
  }
469
+ for (const [regTypeName, typeReg] of ctx.types) {
470
+ if (typeReg.schema.ast === memberAst) {
471
+ const result = ctx.typeRegistry.get(regTypeName);
472
+ if (result) return result;
473
+ }
474
+ }
469
475
  if (memberAst._tag === "Transformation") {
470
476
  const innerToAst = memberAst.to;
471
477
  const transformedTypeName = ctx.astToTypeName?.get(innerToAst);
@@ -473,6 +479,41 @@ function handleTransformationAST(ast, ctx) {
473
479
  const result = ctx.typeRegistry.get(transformedTypeName);
474
480
  if (result) return result;
475
481
  }
482
+ for (const [regTypeName, typeReg] of ctx.types) {
483
+ if (typeReg.schema.ast === innerToAst) {
484
+ const result = ctx.typeRegistry.get(regTypeName);
485
+ if (result) return result;
486
+ }
487
+ }
488
+ }
489
+ if (memberAst._tag === "TypeLiteral") {
490
+ const valueField = memberAst.propertySignatures?.find(
491
+ (p) => String(p.name) === "value"
492
+ );
493
+ if (valueField) {
494
+ const valueType = valueField.type;
495
+ const valueTypeName = ctx.astToTypeName?.get(valueType);
496
+ if (valueTypeName) {
497
+ const result = ctx.typeRegistry.get(valueTypeName);
498
+ if (result) return result;
499
+ }
500
+ for (const [regTypeName, typeReg] of ctx.types) {
501
+ if (typeReg.schema.ast === valueType) {
502
+ const result = ctx.typeRegistry.get(regTypeName);
503
+ if (result) return result;
504
+ }
505
+ let regAst = typeReg.schema.ast;
506
+ while (regAst._tag === "Transformation") {
507
+ regAst = regAst.to;
508
+ if (regAst === valueType) {
509
+ const result = ctx.typeRegistry.get(regTypeName);
510
+ if (result) return result;
511
+ }
512
+ }
513
+ }
514
+ const innerResult = toGraphQLTypeWithRegistry(S2__namespace.make(valueType), ctx);
515
+ if (innerResult) return innerResult;
516
+ }
476
517
  }
477
518
  }
478
519
  }
@@ -509,6 +550,12 @@ function handleUnionAST(ast, ctx) {
509
550
  const result = ctx.typeRegistry.get(typeName);
510
551
  if (result) return result;
511
552
  }
553
+ for (const [regTypeName, typeReg] of ctx.types) {
554
+ if (typeReg.schema.ast === memberAst) {
555
+ const result = ctx.typeRegistry.get(regTypeName);
556
+ if (result) return result;
557
+ }
558
+ }
512
559
  if (memberAst._tag === "Transformation") {
513
560
  const toAst = memberAst.to;
514
561
  const transformedTypeName = ctx.astToTypeName?.get(toAst);
@@ -516,13 +563,39 @@ function handleUnionAST(ast, ctx) {
516
563
  const result = ctx.typeRegistry.get(transformedTypeName);
517
564
  if (result) return result;
518
565
  }
566
+ for (const [regTypeName, typeReg] of ctx.types) {
567
+ if (typeReg.schema.ast === toAst) {
568
+ const result = ctx.typeRegistry.get(regTypeName);
569
+ if (result) return result;
570
+ }
571
+ }
519
572
  }
520
573
  if (memberAst._tag === "TypeLiteral") {
521
574
  const valueField = memberAst.propertySignatures?.find(
522
575
  (p) => String(p.name) === "value"
523
576
  );
524
577
  if (valueField) {
525
- const innerResult = toGraphQLTypeWithRegistry(S2__namespace.make(valueField.type), ctx);
578
+ const valueType = valueField.type;
579
+ const valueTypeName = ctx.astToTypeName?.get(valueType);
580
+ if (valueTypeName) {
581
+ const result = ctx.typeRegistry.get(valueTypeName);
582
+ if (result) return result;
583
+ }
584
+ for (const [regTypeName, typeReg] of ctx.types) {
585
+ if (typeReg.schema.ast === valueType) {
586
+ const result = ctx.typeRegistry.get(regTypeName);
587
+ if (result) return result;
588
+ }
589
+ let regAst = typeReg.schema.ast;
590
+ while (regAst._tag === "Transformation") {
591
+ regAst = regAst.to;
592
+ if (regAst === valueType) {
593
+ const result = ctx.typeRegistry.get(regTypeName);
594
+ if (result) return result;
595
+ }
596
+ }
597
+ }
598
+ const innerResult = toGraphQLTypeWithRegistry(S2__namespace.make(valueType), ctx);
526
599
  if (innerResult) {
527
600
  return innerResult;
528
601
  }
@@ -698,15 +771,57 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
698
771
  if (memberAst._tag === "UndefinedKeyword") continue;
699
772
  const inputName = cache?.astToInputName?.get(memberAst);
700
773
  if (inputName) {
701
- const result = inputRegistry.get(inputName);
702
- if (result) return result;
774
+ const inputReg = inputs.get(inputName);
775
+ if (inputReg) {
776
+ return toGraphQLInputTypeWithRegistry(
777
+ inputReg.schema,
778
+ enumRegistry,
779
+ inputRegistry,
780
+ inputs,
781
+ enums,
782
+ cache
783
+ );
784
+ }
785
+ }
786
+ for (const [, inputReg] of inputs) {
787
+ if (inputReg.schema.ast === memberAst) {
788
+ return toGraphQLInputTypeWithRegistry(
789
+ inputReg.schema,
790
+ enumRegistry,
791
+ inputRegistry,
792
+ inputs,
793
+ enums,
794
+ cache
795
+ );
796
+ }
703
797
  }
704
798
  if (memberAst._tag === "Transformation") {
705
799
  const innerToAst = memberAst.to;
706
800
  const transformedInputName = cache?.astToInputName?.get(innerToAst);
707
801
  if (transformedInputName) {
708
- const result = inputRegistry.get(transformedInputName);
709
- if (result) return result;
802
+ const inputReg = inputs.get(transformedInputName);
803
+ if (inputReg) {
804
+ return toGraphQLInputTypeWithRegistry(
805
+ inputReg.schema,
806
+ enumRegistry,
807
+ inputRegistry,
808
+ inputs,
809
+ enums,
810
+ cache
811
+ );
812
+ }
813
+ }
814
+ for (const [, inputReg] of inputs) {
815
+ if (inputReg.schema.ast === innerToAst) {
816
+ return toGraphQLInputTypeWithRegistry(
817
+ inputReg.schema,
818
+ enumRegistry,
819
+ inputRegistry,
820
+ inputs,
821
+ enums,
822
+ cache
823
+ );
824
+ }
710
825
  }
711
826
  }
712
827
  if (memberAst._tag === "TypeLiteral") {
@@ -714,8 +829,59 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
714
829
  (p) => String(p.name) === "value"
715
830
  );
716
831
  if (valueField) {
832
+ const valueType = valueField.type;
833
+ const valueInputName = cache?.astToInputName?.get(valueType);
834
+ if (valueInputName) {
835
+ const inputReg = inputs.get(valueInputName);
836
+ if (inputReg) {
837
+ return toGraphQLInputTypeWithRegistry(
838
+ inputReg.schema,
839
+ enumRegistry,
840
+ inputRegistry,
841
+ inputs,
842
+ enums,
843
+ cache
844
+ );
845
+ }
846
+ }
847
+ for (const [, inputReg] of inputs) {
848
+ if (inputReg.schema.ast === valueType) {
849
+ return toGraphQLInputTypeWithRegistry(
850
+ inputReg.schema,
851
+ enumRegistry,
852
+ inputRegistry,
853
+ inputs,
854
+ enums,
855
+ cache
856
+ );
857
+ }
858
+ let regAst = inputReg.schema.ast;
859
+ while (regAst._tag === "Transformation") {
860
+ regAst = regAst.to;
861
+ if (regAst === valueType) {
862
+ return toGraphQLInputTypeWithRegistry(
863
+ inputReg.schema,
864
+ enumRegistry,
865
+ inputRegistry,
866
+ inputs,
867
+ enums,
868
+ cache
869
+ );
870
+ }
871
+ }
872
+ if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
873
+ return toGraphQLInputTypeWithRegistry(
874
+ inputReg.schema,
875
+ enumRegistry,
876
+ inputRegistry,
877
+ inputs,
878
+ enums,
879
+ cache
880
+ );
881
+ }
882
+ }
717
883
  const innerResult = toGraphQLInputTypeWithRegistry(
718
- S2__namespace.make(valueField.type),
884
+ S2__namespace.make(valueType),
719
885
  enumRegistry,
720
886
  inputRegistry,
721
887
  inputs,
@@ -764,15 +930,57 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
764
930
  for (const memberAst of unionAst.types) {
765
931
  const inputName = cache?.astToInputName?.get(memberAst);
766
932
  if (inputName) {
767
- const result = inputRegistry.get(inputName);
768
- if (result) return result;
933
+ const inputReg = inputs.get(inputName);
934
+ if (inputReg) {
935
+ return toGraphQLInputTypeWithRegistry(
936
+ inputReg.schema,
937
+ enumRegistry,
938
+ inputRegistry,
939
+ inputs,
940
+ enums,
941
+ cache
942
+ );
943
+ }
944
+ }
945
+ for (const [, inputReg] of inputs) {
946
+ if (inputReg.schema.ast === memberAst) {
947
+ return toGraphQLInputTypeWithRegistry(
948
+ inputReg.schema,
949
+ enumRegistry,
950
+ inputRegistry,
951
+ inputs,
952
+ enums,
953
+ cache
954
+ );
955
+ }
769
956
  }
770
957
  if (memberAst._tag === "Transformation") {
771
958
  const toAst = memberAst.to;
772
959
  const transformedInputName = cache?.astToInputName?.get(toAst);
773
960
  if (transformedInputName) {
774
- const result = inputRegistry.get(transformedInputName);
775
- if (result) return result;
961
+ const inputReg = inputs.get(transformedInputName);
962
+ if (inputReg) {
963
+ return toGraphQLInputTypeWithRegistry(
964
+ inputReg.schema,
965
+ enumRegistry,
966
+ inputRegistry,
967
+ inputs,
968
+ enums,
969
+ cache
970
+ );
971
+ }
972
+ }
973
+ for (const [, inputReg] of inputs) {
974
+ if (inputReg.schema.ast === toAst) {
975
+ return toGraphQLInputTypeWithRegistry(
976
+ inputReg.schema,
977
+ enumRegistry,
978
+ inputRegistry,
979
+ inputs,
980
+ enums,
981
+ cache
982
+ );
983
+ }
776
984
  }
777
985
  }
778
986
  if (memberAst._tag === "TypeLiteral") {
@@ -780,8 +988,59 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
780
988
  (p) => String(p.name) === "value"
781
989
  );
782
990
  if (valueField) {
991
+ const valueType = valueField.type;
992
+ const valueInputName = cache?.astToInputName?.get(valueType);
993
+ if (valueInputName) {
994
+ const inputReg = inputs.get(valueInputName);
995
+ if (inputReg) {
996
+ return toGraphQLInputTypeWithRegistry(
997
+ inputReg.schema,
998
+ enumRegistry,
999
+ inputRegistry,
1000
+ inputs,
1001
+ enums,
1002
+ cache
1003
+ );
1004
+ }
1005
+ }
1006
+ for (const [, inputReg] of inputs) {
1007
+ if (inputReg.schema.ast === valueType) {
1008
+ return toGraphQLInputTypeWithRegistry(
1009
+ inputReg.schema,
1010
+ enumRegistry,
1011
+ inputRegistry,
1012
+ inputs,
1013
+ enums,
1014
+ cache
1015
+ );
1016
+ }
1017
+ let regAst = inputReg.schema.ast;
1018
+ while (regAst._tag === "Transformation") {
1019
+ regAst = regAst.to;
1020
+ if (regAst === valueType) {
1021
+ return toGraphQLInputTypeWithRegistry(
1022
+ inputReg.schema,
1023
+ enumRegistry,
1024
+ inputRegistry,
1025
+ inputs,
1026
+ enums,
1027
+ cache
1028
+ );
1029
+ }
1030
+ }
1031
+ if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
1032
+ return toGraphQLInputTypeWithRegistry(
1033
+ inputReg.schema,
1034
+ enumRegistry,
1035
+ inputRegistry,
1036
+ inputs,
1037
+ enums,
1038
+ cache
1039
+ );
1040
+ }
1041
+ }
783
1042
  const innerResult = toGraphQLInputTypeWithRegistry(
784
- S2__namespace.make(valueField.type),
1043
+ S2__namespace.make(valueType),
785
1044
  enumRegistry,
786
1045
  inputRegistry,
787
1046
  inputs,