@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/index.cjs
CHANGED
|
@@ -771,26 +771,56 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
771
771
|
if (memberAst._tag === "UndefinedKeyword") continue;
|
|
772
772
|
const inputName = cache?.astToInputName?.get(memberAst);
|
|
773
773
|
if (inputName) {
|
|
774
|
-
const
|
|
775
|
-
if (
|
|
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
|
+
}
|
|
776
785
|
}
|
|
777
|
-
for (const [
|
|
786
|
+
for (const [, inputReg] of inputs) {
|
|
778
787
|
if (inputReg.schema.ast === memberAst) {
|
|
779
|
-
|
|
780
|
-
|
|
788
|
+
return toGraphQLInputTypeWithRegistry(
|
|
789
|
+
inputReg.schema,
|
|
790
|
+
enumRegistry,
|
|
791
|
+
inputRegistry,
|
|
792
|
+
inputs,
|
|
793
|
+
enums,
|
|
794
|
+
cache
|
|
795
|
+
);
|
|
781
796
|
}
|
|
782
797
|
}
|
|
783
798
|
if (memberAst._tag === "Transformation") {
|
|
784
799
|
const innerToAst = memberAst.to;
|
|
785
800
|
const transformedInputName = cache?.astToInputName?.get(innerToAst);
|
|
786
801
|
if (transformedInputName) {
|
|
787
|
-
const
|
|
788
|
-
if (
|
|
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
|
+
}
|
|
789
813
|
}
|
|
790
|
-
for (const [
|
|
814
|
+
for (const [, inputReg] of inputs) {
|
|
791
815
|
if (inputReg.schema.ast === innerToAst) {
|
|
792
|
-
|
|
793
|
-
|
|
816
|
+
return toGraphQLInputTypeWithRegistry(
|
|
817
|
+
inputReg.schema,
|
|
818
|
+
enumRegistry,
|
|
819
|
+
inputRegistry,
|
|
820
|
+
inputs,
|
|
821
|
+
enums,
|
|
822
|
+
cache
|
|
823
|
+
);
|
|
794
824
|
}
|
|
795
825
|
}
|
|
796
826
|
}
|
|
@@ -802,25 +832,52 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
802
832
|
const valueType = valueField.type;
|
|
803
833
|
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
804
834
|
if (valueInputName) {
|
|
805
|
-
const
|
|
806
|
-
if (
|
|
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
|
+
}
|
|
807
846
|
}
|
|
808
|
-
for (const [
|
|
847
|
+
for (const [, inputReg] of inputs) {
|
|
809
848
|
if (inputReg.schema.ast === valueType) {
|
|
810
|
-
|
|
811
|
-
|
|
849
|
+
return toGraphQLInputTypeWithRegistry(
|
|
850
|
+
inputReg.schema,
|
|
851
|
+
enumRegistry,
|
|
852
|
+
inputRegistry,
|
|
853
|
+
inputs,
|
|
854
|
+
enums,
|
|
855
|
+
cache
|
|
856
|
+
);
|
|
812
857
|
}
|
|
813
858
|
let regAst = inputReg.schema.ast;
|
|
814
859
|
while (regAst._tag === "Transformation") {
|
|
815
860
|
regAst = regAst.to;
|
|
816
861
|
if (regAst === valueType) {
|
|
817
|
-
|
|
818
|
-
|
|
862
|
+
return toGraphQLInputTypeWithRegistry(
|
|
863
|
+
inputReg.schema,
|
|
864
|
+
enumRegistry,
|
|
865
|
+
inputRegistry,
|
|
866
|
+
inputs,
|
|
867
|
+
enums,
|
|
868
|
+
cache
|
|
869
|
+
);
|
|
819
870
|
}
|
|
820
871
|
}
|
|
821
872
|
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
822
|
-
|
|
823
|
-
|
|
873
|
+
return toGraphQLInputTypeWithRegistry(
|
|
874
|
+
inputReg.schema,
|
|
875
|
+
enumRegistry,
|
|
876
|
+
inputRegistry,
|
|
877
|
+
inputs,
|
|
878
|
+
enums,
|
|
879
|
+
cache
|
|
880
|
+
);
|
|
824
881
|
}
|
|
825
882
|
}
|
|
826
883
|
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
@@ -873,26 +930,56 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
873
930
|
for (const memberAst of unionAst.types) {
|
|
874
931
|
const inputName = cache?.astToInputName?.get(memberAst);
|
|
875
932
|
if (inputName) {
|
|
876
|
-
const
|
|
877
|
-
if (
|
|
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
|
+
}
|
|
878
944
|
}
|
|
879
|
-
for (const [
|
|
945
|
+
for (const [, inputReg] of inputs) {
|
|
880
946
|
if (inputReg.schema.ast === memberAst) {
|
|
881
|
-
|
|
882
|
-
|
|
947
|
+
return toGraphQLInputTypeWithRegistry(
|
|
948
|
+
inputReg.schema,
|
|
949
|
+
enumRegistry,
|
|
950
|
+
inputRegistry,
|
|
951
|
+
inputs,
|
|
952
|
+
enums,
|
|
953
|
+
cache
|
|
954
|
+
);
|
|
883
955
|
}
|
|
884
956
|
}
|
|
885
957
|
if (memberAst._tag === "Transformation") {
|
|
886
958
|
const toAst = memberAst.to;
|
|
887
959
|
const transformedInputName = cache?.astToInputName?.get(toAst);
|
|
888
960
|
if (transformedInputName) {
|
|
889
|
-
const
|
|
890
|
-
if (
|
|
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
|
+
}
|
|
891
972
|
}
|
|
892
|
-
for (const [
|
|
973
|
+
for (const [, inputReg] of inputs) {
|
|
893
974
|
if (inputReg.schema.ast === toAst) {
|
|
894
|
-
|
|
895
|
-
|
|
975
|
+
return toGraphQLInputTypeWithRegistry(
|
|
976
|
+
inputReg.schema,
|
|
977
|
+
enumRegistry,
|
|
978
|
+
inputRegistry,
|
|
979
|
+
inputs,
|
|
980
|
+
enums,
|
|
981
|
+
cache
|
|
982
|
+
);
|
|
896
983
|
}
|
|
897
984
|
}
|
|
898
985
|
}
|
|
@@ -904,25 +991,52 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
904
991
|
const valueType = valueField.type;
|
|
905
992
|
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
906
993
|
if (valueInputName) {
|
|
907
|
-
const
|
|
908
|
-
if (
|
|
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
|
+
}
|
|
909
1005
|
}
|
|
910
|
-
for (const [
|
|
1006
|
+
for (const [, inputReg] of inputs) {
|
|
911
1007
|
if (inputReg.schema.ast === valueType) {
|
|
912
|
-
|
|
913
|
-
|
|
1008
|
+
return toGraphQLInputTypeWithRegistry(
|
|
1009
|
+
inputReg.schema,
|
|
1010
|
+
enumRegistry,
|
|
1011
|
+
inputRegistry,
|
|
1012
|
+
inputs,
|
|
1013
|
+
enums,
|
|
1014
|
+
cache
|
|
1015
|
+
);
|
|
914
1016
|
}
|
|
915
1017
|
let regAst = inputReg.schema.ast;
|
|
916
1018
|
while (regAst._tag === "Transformation") {
|
|
917
1019
|
regAst = regAst.to;
|
|
918
1020
|
if (regAst === valueType) {
|
|
919
|
-
|
|
920
|
-
|
|
1021
|
+
return toGraphQLInputTypeWithRegistry(
|
|
1022
|
+
inputReg.schema,
|
|
1023
|
+
enumRegistry,
|
|
1024
|
+
inputRegistry,
|
|
1025
|
+
inputs,
|
|
1026
|
+
enums,
|
|
1027
|
+
cache
|
|
1028
|
+
);
|
|
921
1029
|
}
|
|
922
1030
|
}
|
|
923
1031
|
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
924
|
-
|
|
925
|
-
|
|
1032
|
+
return toGraphQLInputTypeWithRegistry(
|
|
1033
|
+
inputReg.schema,
|
|
1034
|
+
enumRegistry,
|
|
1035
|
+
inputRegistry,
|
|
1036
|
+
inputs,
|
|
1037
|
+
enums,
|
|
1038
|
+
cache
|
|
1039
|
+
);
|
|
926
1040
|
}
|
|
927
1041
|
}
|
|
928
1042
|
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
@@ -1537,15 +1651,25 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1537
1651
|
}
|
|
1538
1652
|
/**
|
|
1539
1653
|
* Build the GraphQL schema (no services required)
|
|
1654
|
+
*
|
|
1655
|
+
* Uses a two-phase approach:
|
|
1656
|
+
* 1. Phase 1: Build enum and input registries first (these may be referenced by other types)
|
|
1657
|
+
* 2. Phase 2: Build interface, object, and union types (which may reference inputs in args)
|
|
1658
|
+
*
|
|
1659
|
+
* This ensures that when object type fields with args are processed,
|
|
1660
|
+
* all registered input types are already available in the inputRegistry.
|
|
1540
1661
|
*/
|
|
1541
1662
|
buildSchema() {
|
|
1542
|
-
const directiveRegistry = this.buildDirectiveRegistry();
|
|
1543
1663
|
const enumRegistry = this.buildEnumRegistry();
|
|
1544
1664
|
const inputRegistry = this.buildInputRegistry(enumRegistry);
|
|
1545
|
-
const
|
|
1665
|
+
const inputTypeLookupCache = buildInputTypeLookupCache(this.state.inputs, this.state.enums);
|
|
1666
|
+
const directiveRegistry = this.buildDirectiveRegistry(enumRegistry, inputRegistry, inputTypeLookupCache);
|
|
1667
|
+
const interfaceRegistry = this.buildInterfaceRegistry(enumRegistry, inputRegistry, inputTypeLookupCache);
|
|
1546
1668
|
const { typeRegistry, unionRegistry } = this.buildTypeAndUnionRegistries(
|
|
1547
1669
|
enumRegistry,
|
|
1548
|
-
interfaceRegistry
|
|
1670
|
+
interfaceRegistry,
|
|
1671
|
+
inputRegistry,
|
|
1672
|
+
inputTypeLookupCache
|
|
1549
1673
|
);
|
|
1550
1674
|
const fieldCtx = this.createFieldBuilderContext(
|
|
1551
1675
|
typeRegistry,
|
|
@@ -1569,9 +1693,8 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1569
1693
|
subscriptionFields
|
|
1570
1694
|
});
|
|
1571
1695
|
}
|
|
1572
|
-
buildDirectiveRegistry() {
|
|
1696
|
+
buildDirectiveRegistry(enumRegistry, inputRegistry, cache) {
|
|
1573
1697
|
const registry = /* @__PURE__ */ new Map();
|
|
1574
|
-
const cache = buildInputTypeLookupCache(this.state.inputs, this.state.enums);
|
|
1575
1698
|
for (const [name, reg] of this.state.directives) {
|
|
1576
1699
|
const graphqlDirective = new graphql.GraphQLDirective({
|
|
1577
1700
|
name,
|
|
@@ -1579,8 +1702,8 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1579
1702
|
locations: [...reg.locations],
|
|
1580
1703
|
args: reg.args ? toGraphQLArgsWithRegistry(
|
|
1581
1704
|
reg.args,
|
|
1582
|
-
|
|
1583
|
-
|
|
1705
|
+
enumRegistry,
|
|
1706
|
+
inputRegistry,
|
|
1584
1707
|
this.state.inputs,
|
|
1585
1708
|
this.state.enums,
|
|
1586
1709
|
cache
|
|
@@ -1630,7 +1753,7 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1630
1753
|
}
|
|
1631
1754
|
return registry;
|
|
1632
1755
|
}
|
|
1633
|
-
buildInterfaceRegistry(enumRegistry) {
|
|
1756
|
+
buildInterfaceRegistry(enumRegistry, inputRegistry, _cache) {
|
|
1634
1757
|
const registry = /* @__PURE__ */ new Map();
|
|
1635
1758
|
const typeRegistry = /* @__PURE__ */ new Map();
|
|
1636
1759
|
const unionRegistry = /* @__PURE__ */ new Map();
|
|
@@ -1656,7 +1779,7 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1656
1779
|
}
|
|
1657
1780
|
return registry;
|
|
1658
1781
|
}
|
|
1659
|
-
buildTypeAndUnionRegistries(enumRegistry, interfaceRegistry) {
|
|
1782
|
+
buildTypeAndUnionRegistries(enumRegistry, interfaceRegistry, inputRegistry, inputTypeLookupCache) {
|
|
1660
1783
|
const typeRegistry = /* @__PURE__ */ new Map();
|
|
1661
1784
|
const unionRegistry = /* @__PURE__ */ new Map();
|
|
1662
1785
|
const sharedCtx = {
|
|
@@ -1665,18 +1788,19 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1665
1788
|
enums: this.state.enums,
|
|
1666
1789
|
unions: this.state.unions,
|
|
1667
1790
|
inputs: this.state.inputs,
|
|
1668
|
-
typeRegistry,
|
|
1669
|
-
interfaceRegistry,
|
|
1670
|
-
enumRegistry,
|
|
1671
|
-
unionRegistry};
|
|
1672
|
-
buildReverseLookups(sharedCtx);
|
|
1673
|
-
const sharedFieldCtx = this.createFieldBuilderContext(
|
|
1674
1791
|
typeRegistry,
|
|
1675
1792
|
interfaceRegistry,
|
|
1676
1793
|
enumRegistry,
|
|
1677
1794
|
unionRegistry,
|
|
1678
|
-
|
|
1679
|
-
|
|
1795
|
+
inputRegistry
|
|
1796
|
+
};
|
|
1797
|
+
buildReverseLookups(sharedCtx);
|
|
1798
|
+
const sharedFieldCtx = {
|
|
1799
|
+
...sharedCtx,
|
|
1800
|
+
directiveRegistrations: this.state.directives,
|
|
1801
|
+
middlewares: this.state.middlewares,
|
|
1802
|
+
inputTypeLookupCache
|
|
1803
|
+
};
|
|
1680
1804
|
for (const [typeName, typeReg] of this.state.types) {
|
|
1681
1805
|
const implementedInterfaces = typeReg.implements?.map((name) => interfaceRegistry.get(name)).filter(Boolean) ?? [];
|
|
1682
1806
|
const graphqlType = new graphql.GraphQLObjectType({
|