@effect-gql/core 1.4.5 → 1.4.7
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 +179 -55
- package/builder/index.cjs.map +1 -1
- package/builder/index.d.cts +2 -2
- package/builder/index.d.ts +2 -2
- package/builder/index.js +179 -55
- package/builder/index.js.map +1 -1
- package/index.cjs +179 -55
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -2
- package/index.d.ts +2 -2
- package/index.js +179 -55
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/{schema-builder-DKvkzU_M.d.cts → schema-builder-CAij36fD.d.cts} +7 -0
- package/{schema-builder-DKvkzU_M.d.ts → schema-builder-CAij36fD.d.ts} +7 -0
- package/server/index.d.cts +2 -2
- package/server/index.d.ts +2 -2
package/builder/index.cjs
CHANGED
|
@@ -722,26 +722,56 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
722
722
|
if (memberAst._tag === "UndefinedKeyword") continue;
|
|
723
723
|
const inputName = cache?.astToInputName?.get(memberAst);
|
|
724
724
|
if (inputName) {
|
|
725
|
-
const
|
|
726
|
-
if (
|
|
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
|
+
}
|
|
727
736
|
}
|
|
728
|
-
for (const [
|
|
737
|
+
for (const [, inputReg] of inputs) {
|
|
729
738
|
if (inputReg.schema.ast === memberAst) {
|
|
730
|
-
|
|
731
|
-
|
|
739
|
+
return toGraphQLInputTypeWithRegistry(
|
|
740
|
+
inputReg.schema,
|
|
741
|
+
enumRegistry,
|
|
742
|
+
inputRegistry,
|
|
743
|
+
inputs,
|
|
744
|
+
enums,
|
|
745
|
+
cache
|
|
746
|
+
);
|
|
732
747
|
}
|
|
733
748
|
}
|
|
734
749
|
if (memberAst._tag === "Transformation") {
|
|
735
750
|
const innerToAst = memberAst.to;
|
|
736
751
|
const transformedInputName = cache?.astToInputName?.get(innerToAst);
|
|
737
752
|
if (transformedInputName) {
|
|
738
|
-
const
|
|
739
|
-
if (
|
|
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
|
+
}
|
|
740
764
|
}
|
|
741
|
-
for (const [
|
|
765
|
+
for (const [, inputReg] of inputs) {
|
|
742
766
|
if (inputReg.schema.ast === innerToAst) {
|
|
743
|
-
|
|
744
|
-
|
|
767
|
+
return toGraphQLInputTypeWithRegistry(
|
|
768
|
+
inputReg.schema,
|
|
769
|
+
enumRegistry,
|
|
770
|
+
inputRegistry,
|
|
771
|
+
inputs,
|
|
772
|
+
enums,
|
|
773
|
+
cache
|
|
774
|
+
);
|
|
745
775
|
}
|
|
746
776
|
}
|
|
747
777
|
}
|
|
@@ -753,25 +783,52 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
753
783
|
const valueType = valueField.type;
|
|
754
784
|
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
755
785
|
if (valueInputName) {
|
|
756
|
-
const
|
|
757
|
-
if (
|
|
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
|
+
}
|
|
758
797
|
}
|
|
759
|
-
for (const [
|
|
798
|
+
for (const [, inputReg] of inputs) {
|
|
760
799
|
if (inputReg.schema.ast === valueType) {
|
|
761
|
-
|
|
762
|
-
|
|
800
|
+
return toGraphQLInputTypeWithRegistry(
|
|
801
|
+
inputReg.schema,
|
|
802
|
+
enumRegistry,
|
|
803
|
+
inputRegistry,
|
|
804
|
+
inputs,
|
|
805
|
+
enums,
|
|
806
|
+
cache
|
|
807
|
+
);
|
|
763
808
|
}
|
|
764
809
|
let regAst = inputReg.schema.ast;
|
|
765
810
|
while (regAst._tag === "Transformation") {
|
|
766
811
|
regAst = regAst.to;
|
|
767
812
|
if (regAst === valueType) {
|
|
768
|
-
|
|
769
|
-
|
|
813
|
+
return toGraphQLInputTypeWithRegistry(
|
|
814
|
+
inputReg.schema,
|
|
815
|
+
enumRegistry,
|
|
816
|
+
inputRegistry,
|
|
817
|
+
inputs,
|
|
818
|
+
enums,
|
|
819
|
+
cache
|
|
820
|
+
);
|
|
770
821
|
}
|
|
771
822
|
}
|
|
772
823
|
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
773
|
-
|
|
774
|
-
|
|
824
|
+
return toGraphQLInputTypeWithRegistry(
|
|
825
|
+
inputReg.schema,
|
|
826
|
+
enumRegistry,
|
|
827
|
+
inputRegistry,
|
|
828
|
+
inputs,
|
|
829
|
+
enums,
|
|
830
|
+
cache
|
|
831
|
+
);
|
|
775
832
|
}
|
|
776
833
|
}
|
|
777
834
|
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
@@ -824,26 +881,56 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
824
881
|
for (const memberAst of unionAst.types) {
|
|
825
882
|
const inputName = cache?.astToInputName?.get(memberAst);
|
|
826
883
|
if (inputName) {
|
|
827
|
-
const
|
|
828
|
-
if (
|
|
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
|
+
}
|
|
829
895
|
}
|
|
830
|
-
for (const [
|
|
896
|
+
for (const [, inputReg] of inputs) {
|
|
831
897
|
if (inputReg.schema.ast === memberAst) {
|
|
832
|
-
|
|
833
|
-
|
|
898
|
+
return toGraphQLInputTypeWithRegistry(
|
|
899
|
+
inputReg.schema,
|
|
900
|
+
enumRegistry,
|
|
901
|
+
inputRegistry,
|
|
902
|
+
inputs,
|
|
903
|
+
enums,
|
|
904
|
+
cache
|
|
905
|
+
);
|
|
834
906
|
}
|
|
835
907
|
}
|
|
836
908
|
if (memberAst._tag === "Transformation") {
|
|
837
909
|
const toAst = memberAst.to;
|
|
838
910
|
const transformedInputName = cache?.astToInputName?.get(toAst);
|
|
839
911
|
if (transformedInputName) {
|
|
840
|
-
const
|
|
841
|
-
if (
|
|
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
|
+
}
|
|
842
923
|
}
|
|
843
|
-
for (const [
|
|
924
|
+
for (const [, inputReg] of inputs) {
|
|
844
925
|
if (inputReg.schema.ast === toAst) {
|
|
845
|
-
|
|
846
|
-
|
|
926
|
+
return toGraphQLInputTypeWithRegistry(
|
|
927
|
+
inputReg.schema,
|
|
928
|
+
enumRegistry,
|
|
929
|
+
inputRegistry,
|
|
930
|
+
inputs,
|
|
931
|
+
enums,
|
|
932
|
+
cache
|
|
933
|
+
);
|
|
847
934
|
}
|
|
848
935
|
}
|
|
849
936
|
}
|
|
@@ -855,25 +942,52 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
855
942
|
const valueType = valueField.type;
|
|
856
943
|
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
857
944
|
if (valueInputName) {
|
|
858
|
-
const
|
|
859
|
-
if (
|
|
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
|
+
}
|
|
860
956
|
}
|
|
861
|
-
for (const [
|
|
957
|
+
for (const [, inputReg] of inputs) {
|
|
862
958
|
if (inputReg.schema.ast === valueType) {
|
|
863
|
-
|
|
864
|
-
|
|
959
|
+
return toGraphQLInputTypeWithRegistry(
|
|
960
|
+
inputReg.schema,
|
|
961
|
+
enumRegistry,
|
|
962
|
+
inputRegistry,
|
|
963
|
+
inputs,
|
|
964
|
+
enums,
|
|
965
|
+
cache
|
|
966
|
+
);
|
|
865
967
|
}
|
|
866
968
|
let regAst = inputReg.schema.ast;
|
|
867
969
|
while (regAst._tag === "Transformation") {
|
|
868
970
|
regAst = regAst.to;
|
|
869
971
|
if (regAst === valueType) {
|
|
870
|
-
|
|
871
|
-
|
|
972
|
+
return toGraphQLInputTypeWithRegistry(
|
|
973
|
+
inputReg.schema,
|
|
974
|
+
enumRegistry,
|
|
975
|
+
inputRegistry,
|
|
976
|
+
inputs,
|
|
977
|
+
enums,
|
|
978
|
+
cache
|
|
979
|
+
);
|
|
872
980
|
}
|
|
873
981
|
}
|
|
874
982
|
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
875
|
-
|
|
876
|
-
|
|
983
|
+
return toGraphQLInputTypeWithRegistry(
|
|
984
|
+
inputReg.schema,
|
|
985
|
+
enumRegistry,
|
|
986
|
+
inputRegistry,
|
|
987
|
+
inputs,
|
|
988
|
+
enums,
|
|
989
|
+
cache
|
|
990
|
+
);
|
|
877
991
|
}
|
|
878
992
|
}
|
|
879
993
|
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
@@ -1488,15 +1602,25 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1488
1602
|
}
|
|
1489
1603
|
/**
|
|
1490
1604
|
* Build the GraphQL schema (no services required)
|
|
1605
|
+
*
|
|
1606
|
+
* Uses a two-phase approach:
|
|
1607
|
+
* 1. Phase 1: Build enum and input registries first (these may be referenced by other types)
|
|
1608
|
+
* 2. Phase 2: Build interface, object, and union types (which may reference inputs in args)
|
|
1609
|
+
*
|
|
1610
|
+
* This ensures that when object type fields with args are processed,
|
|
1611
|
+
* all registered input types are already available in the inputRegistry.
|
|
1491
1612
|
*/
|
|
1492
1613
|
buildSchema() {
|
|
1493
|
-
const directiveRegistry = this.buildDirectiveRegistry();
|
|
1494
1614
|
const enumRegistry = this.buildEnumRegistry();
|
|
1495
1615
|
const inputRegistry = this.buildInputRegistry(enumRegistry);
|
|
1496
|
-
const
|
|
1616
|
+
const inputTypeLookupCache = buildInputTypeLookupCache(this.state.inputs, this.state.enums);
|
|
1617
|
+
const directiveRegistry = this.buildDirectiveRegistry(enumRegistry, inputRegistry, inputTypeLookupCache);
|
|
1618
|
+
const interfaceRegistry = this.buildInterfaceRegistry(enumRegistry, inputRegistry, inputTypeLookupCache);
|
|
1497
1619
|
const { typeRegistry, unionRegistry } = this.buildTypeAndUnionRegistries(
|
|
1498
1620
|
enumRegistry,
|
|
1499
|
-
interfaceRegistry
|
|
1621
|
+
interfaceRegistry,
|
|
1622
|
+
inputRegistry,
|
|
1623
|
+
inputTypeLookupCache
|
|
1500
1624
|
);
|
|
1501
1625
|
const fieldCtx = this.createFieldBuilderContext(
|
|
1502
1626
|
typeRegistry,
|
|
@@ -1520,9 +1644,8 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1520
1644
|
subscriptionFields
|
|
1521
1645
|
});
|
|
1522
1646
|
}
|
|
1523
|
-
buildDirectiveRegistry() {
|
|
1647
|
+
buildDirectiveRegistry(enumRegistry, inputRegistry, cache) {
|
|
1524
1648
|
const registry = /* @__PURE__ */ new Map();
|
|
1525
|
-
const cache = buildInputTypeLookupCache(this.state.inputs, this.state.enums);
|
|
1526
1649
|
for (const [name, reg] of this.state.directives) {
|
|
1527
1650
|
const graphqlDirective = new graphql.GraphQLDirective({
|
|
1528
1651
|
name,
|
|
@@ -1530,8 +1653,8 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1530
1653
|
locations: [...reg.locations],
|
|
1531
1654
|
args: reg.args ? toGraphQLArgsWithRegistry(
|
|
1532
1655
|
reg.args,
|
|
1533
|
-
|
|
1534
|
-
|
|
1656
|
+
enumRegistry,
|
|
1657
|
+
inputRegistry,
|
|
1535
1658
|
this.state.inputs,
|
|
1536
1659
|
this.state.enums,
|
|
1537
1660
|
cache
|
|
@@ -1581,7 +1704,7 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1581
1704
|
}
|
|
1582
1705
|
return registry;
|
|
1583
1706
|
}
|
|
1584
|
-
buildInterfaceRegistry(enumRegistry) {
|
|
1707
|
+
buildInterfaceRegistry(enumRegistry, inputRegistry, _cache) {
|
|
1585
1708
|
const registry = /* @__PURE__ */ new Map();
|
|
1586
1709
|
const typeRegistry = /* @__PURE__ */ new Map();
|
|
1587
1710
|
const unionRegistry = /* @__PURE__ */ new Map();
|
|
@@ -1607,7 +1730,7 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1607
1730
|
}
|
|
1608
1731
|
return registry;
|
|
1609
1732
|
}
|
|
1610
|
-
buildTypeAndUnionRegistries(enumRegistry, interfaceRegistry) {
|
|
1733
|
+
buildTypeAndUnionRegistries(enumRegistry, interfaceRegistry, inputRegistry, inputTypeLookupCache) {
|
|
1611
1734
|
const typeRegistry = /* @__PURE__ */ new Map();
|
|
1612
1735
|
const unionRegistry = /* @__PURE__ */ new Map();
|
|
1613
1736
|
const sharedCtx = {
|
|
@@ -1616,18 +1739,19 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1616
1739
|
enums: this.state.enums,
|
|
1617
1740
|
unions: this.state.unions,
|
|
1618
1741
|
inputs: this.state.inputs,
|
|
1619
|
-
typeRegistry,
|
|
1620
|
-
interfaceRegistry,
|
|
1621
|
-
enumRegistry,
|
|
1622
|
-
unionRegistry};
|
|
1623
|
-
buildReverseLookups(sharedCtx);
|
|
1624
|
-
const sharedFieldCtx = this.createFieldBuilderContext(
|
|
1625
1742
|
typeRegistry,
|
|
1626
1743
|
interfaceRegistry,
|
|
1627
1744
|
enumRegistry,
|
|
1628
1745
|
unionRegistry,
|
|
1629
|
-
|
|
1630
|
-
|
|
1746
|
+
inputRegistry
|
|
1747
|
+
};
|
|
1748
|
+
buildReverseLookups(sharedCtx);
|
|
1749
|
+
const sharedFieldCtx = {
|
|
1750
|
+
...sharedCtx,
|
|
1751
|
+
directiveRegistrations: this.state.directives,
|
|
1752
|
+
middlewares: this.state.middlewares,
|
|
1753
|
+
inputTypeLookupCache
|
|
1754
|
+
};
|
|
1631
1755
|
for (const [typeName, typeReg] of this.state.types) {
|
|
1632
1756
|
const implementedInterfaces = typeReg.implements?.map((name) => interfaceRegistry.get(name)).filter(Boolean) ?? [];
|
|
1633
1757
|
const graphqlType = new graphql.GraphQLObjectType({
|