@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 CHANGED
@@ -417,6 +417,12 @@ function handleTransformationAST(ast, ctx) {
417
417
  const result = ctx.typeRegistry.get(typeName);
418
418
  if (result) return result;
419
419
  }
420
+ for (const [regTypeName, typeReg] of ctx.types) {
421
+ if (typeReg.schema.ast === memberAst) {
422
+ const result = ctx.typeRegistry.get(regTypeName);
423
+ if (result) return result;
424
+ }
425
+ }
420
426
  if (memberAst._tag === "Transformation") {
421
427
  const innerToAst = memberAst.to;
422
428
  const transformedTypeName = ctx.astToTypeName?.get(innerToAst);
@@ -424,6 +430,41 @@ function handleTransformationAST(ast, ctx) {
424
430
  const result = ctx.typeRegistry.get(transformedTypeName);
425
431
  if (result) return result;
426
432
  }
433
+ for (const [regTypeName, typeReg] of ctx.types) {
434
+ if (typeReg.schema.ast === innerToAst) {
435
+ const result = ctx.typeRegistry.get(regTypeName);
436
+ if (result) return result;
437
+ }
438
+ }
439
+ }
440
+ if (memberAst._tag === "TypeLiteral") {
441
+ const valueField = memberAst.propertySignatures?.find(
442
+ (p) => String(p.name) === "value"
443
+ );
444
+ if (valueField) {
445
+ const valueType = valueField.type;
446
+ const valueTypeName = ctx.astToTypeName?.get(valueType);
447
+ if (valueTypeName) {
448
+ const result = ctx.typeRegistry.get(valueTypeName);
449
+ if (result) return result;
450
+ }
451
+ for (const [regTypeName, typeReg] of ctx.types) {
452
+ if (typeReg.schema.ast === valueType) {
453
+ const result = ctx.typeRegistry.get(regTypeName);
454
+ if (result) return result;
455
+ }
456
+ let regAst = typeReg.schema.ast;
457
+ while (regAst._tag === "Transformation") {
458
+ regAst = regAst.to;
459
+ if (regAst === valueType) {
460
+ const result = ctx.typeRegistry.get(regTypeName);
461
+ if (result) return result;
462
+ }
463
+ }
464
+ }
465
+ const innerResult = toGraphQLTypeWithRegistry(S2__namespace.make(valueType), ctx);
466
+ if (innerResult) return innerResult;
467
+ }
427
468
  }
428
469
  }
429
470
  }
@@ -460,6 +501,12 @@ function handleUnionAST(ast, ctx) {
460
501
  const result = ctx.typeRegistry.get(typeName);
461
502
  if (result) return result;
462
503
  }
504
+ for (const [regTypeName, typeReg] of ctx.types) {
505
+ if (typeReg.schema.ast === memberAst) {
506
+ const result = ctx.typeRegistry.get(regTypeName);
507
+ if (result) return result;
508
+ }
509
+ }
463
510
  if (memberAst._tag === "Transformation") {
464
511
  const toAst = memberAst.to;
465
512
  const transformedTypeName = ctx.astToTypeName?.get(toAst);
@@ -467,13 +514,39 @@ function handleUnionAST(ast, ctx) {
467
514
  const result = ctx.typeRegistry.get(transformedTypeName);
468
515
  if (result) return result;
469
516
  }
517
+ for (const [regTypeName, typeReg] of ctx.types) {
518
+ if (typeReg.schema.ast === toAst) {
519
+ const result = ctx.typeRegistry.get(regTypeName);
520
+ if (result) return result;
521
+ }
522
+ }
470
523
  }
471
524
  if (memberAst._tag === "TypeLiteral") {
472
525
  const valueField = memberAst.propertySignatures?.find(
473
526
  (p) => String(p.name) === "value"
474
527
  );
475
528
  if (valueField) {
476
- const innerResult = toGraphQLTypeWithRegistry(S2__namespace.make(valueField.type), ctx);
529
+ const valueType = valueField.type;
530
+ const valueTypeName = ctx.astToTypeName?.get(valueType);
531
+ if (valueTypeName) {
532
+ const result = ctx.typeRegistry.get(valueTypeName);
533
+ if (result) return result;
534
+ }
535
+ for (const [regTypeName, typeReg] of ctx.types) {
536
+ if (typeReg.schema.ast === valueType) {
537
+ const result = ctx.typeRegistry.get(regTypeName);
538
+ if (result) return result;
539
+ }
540
+ let regAst = typeReg.schema.ast;
541
+ while (regAst._tag === "Transformation") {
542
+ regAst = regAst.to;
543
+ if (regAst === valueType) {
544
+ const result = ctx.typeRegistry.get(regTypeName);
545
+ if (result) return result;
546
+ }
547
+ }
548
+ }
549
+ const innerResult = toGraphQLTypeWithRegistry(S2__namespace.make(valueType), ctx);
477
550
  if (innerResult) {
478
551
  return innerResult;
479
552
  }
@@ -649,15 +722,57 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
649
722
  if (memberAst._tag === "UndefinedKeyword") continue;
650
723
  const inputName = cache?.astToInputName?.get(memberAst);
651
724
  if (inputName) {
652
- const result = inputRegistry.get(inputName);
653
- if (result) return result;
725
+ const inputReg = inputs.get(inputName);
726
+ if (inputReg) {
727
+ return toGraphQLInputTypeWithRegistry(
728
+ inputReg.schema,
729
+ enumRegistry,
730
+ inputRegistry,
731
+ inputs,
732
+ enums,
733
+ cache
734
+ );
735
+ }
736
+ }
737
+ for (const [, inputReg] of inputs) {
738
+ if (inputReg.schema.ast === memberAst) {
739
+ return toGraphQLInputTypeWithRegistry(
740
+ inputReg.schema,
741
+ enumRegistry,
742
+ inputRegistry,
743
+ inputs,
744
+ enums,
745
+ cache
746
+ );
747
+ }
654
748
  }
655
749
  if (memberAst._tag === "Transformation") {
656
750
  const innerToAst = memberAst.to;
657
751
  const transformedInputName = cache?.astToInputName?.get(innerToAst);
658
752
  if (transformedInputName) {
659
- const result = inputRegistry.get(transformedInputName);
660
- if (result) return result;
753
+ const inputReg = inputs.get(transformedInputName);
754
+ if (inputReg) {
755
+ return toGraphQLInputTypeWithRegistry(
756
+ inputReg.schema,
757
+ enumRegistry,
758
+ inputRegistry,
759
+ inputs,
760
+ enums,
761
+ cache
762
+ );
763
+ }
764
+ }
765
+ for (const [, inputReg] of inputs) {
766
+ if (inputReg.schema.ast === innerToAst) {
767
+ return toGraphQLInputTypeWithRegistry(
768
+ inputReg.schema,
769
+ enumRegistry,
770
+ inputRegistry,
771
+ inputs,
772
+ enums,
773
+ cache
774
+ );
775
+ }
661
776
  }
662
777
  }
663
778
  if (memberAst._tag === "TypeLiteral") {
@@ -665,8 +780,59 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
665
780
  (p) => String(p.name) === "value"
666
781
  );
667
782
  if (valueField) {
783
+ const valueType = valueField.type;
784
+ const valueInputName = cache?.astToInputName?.get(valueType);
785
+ if (valueInputName) {
786
+ const inputReg = inputs.get(valueInputName);
787
+ if (inputReg) {
788
+ return toGraphQLInputTypeWithRegistry(
789
+ inputReg.schema,
790
+ enumRegistry,
791
+ inputRegistry,
792
+ inputs,
793
+ enums,
794
+ cache
795
+ );
796
+ }
797
+ }
798
+ for (const [, inputReg] of inputs) {
799
+ if (inputReg.schema.ast === valueType) {
800
+ return toGraphQLInputTypeWithRegistry(
801
+ inputReg.schema,
802
+ enumRegistry,
803
+ inputRegistry,
804
+ inputs,
805
+ enums,
806
+ cache
807
+ );
808
+ }
809
+ let regAst = inputReg.schema.ast;
810
+ while (regAst._tag === "Transformation") {
811
+ regAst = regAst.to;
812
+ if (regAst === valueType) {
813
+ return toGraphQLInputTypeWithRegistry(
814
+ inputReg.schema,
815
+ enumRegistry,
816
+ inputRegistry,
817
+ inputs,
818
+ enums,
819
+ cache
820
+ );
821
+ }
822
+ }
823
+ if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
824
+ return toGraphQLInputTypeWithRegistry(
825
+ inputReg.schema,
826
+ enumRegistry,
827
+ inputRegistry,
828
+ inputs,
829
+ enums,
830
+ cache
831
+ );
832
+ }
833
+ }
668
834
  const innerResult = toGraphQLInputTypeWithRegistry(
669
- S2__namespace.make(valueField.type),
835
+ S2__namespace.make(valueType),
670
836
  enumRegistry,
671
837
  inputRegistry,
672
838
  inputs,
@@ -715,15 +881,57 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
715
881
  for (const memberAst of unionAst.types) {
716
882
  const inputName = cache?.astToInputName?.get(memberAst);
717
883
  if (inputName) {
718
- const result = inputRegistry.get(inputName);
719
- if (result) return result;
884
+ const inputReg = inputs.get(inputName);
885
+ if (inputReg) {
886
+ return toGraphQLInputTypeWithRegistry(
887
+ inputReg.schema,
888
+ enumRegistry,
889
+ inputRegistry,
890
+ inputs,
891
+ enums,
892
+ cache
893
+ );
894
+ }
895
+ }
896
+ for (const [, inputReg] of inputs) {
897
+ if (inputReg.schema.ast === memberAst) {
898
+ return toGraphQLInputTypeWithRegistry(
899
+ inputReg.schema,
900
+ enumRegistry,
901
+ inputRegistry,
902
+ inputs,
903
+ enums,
904
+ cache
905
+ );
906
+ }
720
907
  }
721
908
  if (memberAst._tag === "Transformation") {
722
909
  const toAst = memberAst.to;
723
910
  const transformedInputName = cache?.astToInputName?.get(toAst);
724
911
  if (transformedInputName) {
725
- const result = inputRegistry.get(transformedInputName);
726
- if (result) return result;
912
+ const inputReg = inputs.get(transformedInputName);
913
+ if (inputReg) {
914
+ return toGraphQLInputTypeWithRegistry(
915
+ inputReg.schema,
916
+ enumRegistry,
917
+ inputRegistry,
918
+ inputs,
919
+ enums,
920
+ cache
921
+ );
922
+ }
923
+ }
924
+ for (const [, inputReg] of inputs) {
925
+ if (inputReg.schema.ast === toAst) {
926
+ return toGraphQLInputTypeWithRegistry(
927
+ inputReg.schema,
928
+ enumRegistry,
929
+ inputRegistry,
930
+ inputs,
931
+ enums,
932
+ cache
933
+ );
934
+ }
727
935
  }
728
936
  }
729
937
  if (memberAst._tag === "TypeLiteral") {
@@ -731,8 +939,59 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
731
939
  (p) => String(p.name) === "value"
732
940
  );
733
941
  if (valueField) {
942
+ const valueType = valueField.type;
943
+ const valueInputName = cache?.astToInputName?.get(valueType);
944
+ if (valueInputName) {
945
+ const inputReg = inputs.get(valueInputName);
946
+ if (inputReg) {
947
+ return toGraphQLInputTypeWithRegistry(
948
+ inputReg.schema,
949
+ enumRegistry,
950
+ inputRegistry,
951
+ inputs,
952
+ enums,
953
+ cache
954
+ );
955
+ }
956
+ }
957
+ for (const [, inputReg] of inputs) {
958
+ if (inputReg.schema.ast === valueType) {
959
+ return toGraphQLInputTypeWithRegistry(
960
+ inputReg.schema,
961
+ enumRegistry,
962
+ inputRegistry,
963
+ inputs,
964
+ enums,
965
+ cache
966
+ );
967
+ }
968
+ let regAst = inputReg.schema.ast;
969
+ while (regAst._tag === "Transformation") {
970
+ regAst = regAst.to;
971
+ if (regAst === valueType) {
972
+ return toGraphQLInputTypeWithRegistry(
973
+ inputReg.schema,
974
+ enumRegistry,
975
+ inputRegistry,
976
+ inputs,
977
+ enums,
978
+ cache
979
+ );
980
+ }
981
+ }
982
+ if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
983
+ return toGraphQLInputTypeWithRegistry(
984
+ inputReg.schema,
985
+ enumRegistry,
986
+ inputRegistry,
987
+ inputs,
988
+ enums,
989
+ cache
990
+ );
991
+ }
992
+ }
734
993
  const innerResult = toGraphQLInputTypeWithRegistry(
735
- S2__namespace.make(valueField.type),
994
+ S2__namespace.make(valueType),
736
995
  enumRegistry,
737
996
  inputRegistry,
738
997
  inputs,