@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.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DirectiveApplication, C as CacheHint, o as FieldComplexity, i as GraphQLSchemaBuilder, M as MiddlewareContext, K as ExecutionArgs, G as GraphQLExtension, F as FieldComplexityMap } from '../schema-builder-
|
|
2
|
-
export { h as CacheControlScope, d as DirectiveRegistration, b as EnumRegistration, a as FieldRegistration, f as GraphQLEffectContext, c as InputTypeRegistration, I as InterfaceRegistration, e as MiddlewareRegistration, O as ObjectFieldRegistration, S as SubscriptionFieldRegistration, T as TypeRegistration, g as TypeRegistries, U as UnionRegistration } from '../schema-builder-
|
|
1
|
+
import { D as DirectiveApplication, C as CacheHint, o as FieldComplexity, i as GraphQLSchemaBuilder, M as MiddlewareContext, K as ExecutionArgs, G as GraphQLExtension, F as FieldComplexityMap } from '../schema-builder-CAij36fD.cjs';
|
|
2
|
+
export { h as CacheControlScope, d as DirectiveRegistration, b as EnumRegistration, a as FieldRegistration, f as GraphQLEffectContext, c as InputTypeRegistration, I as InterfaceRegistration, e as MiddlewareRegistration, O as ObjectFieldRegistration, S as SubscriptionFieldRegistration, T as TypeRegistration, g as TypeRegistries, U as UnionRegistration } from '../schema-builder-CAij36fD.cjs';
|
|
3
3
|
import { DirectiveLocation, GraphQLResolveInfo, DocumentNode, GraphQLError, ExecutionResult, GraphQLSchema } from 'graphql';
|
|
4
4
|
export { DirectiveLocation } from 'graphql';
|
|
5
5
|
import { Effect, Stream, Layer } from 'effect';
|
package/builder/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DirectiveApplication, C as CacheHint, o as FieldComplexity, i as GraphQLSchemaBuilder, M as MiddlewareContext, K as ExecutionArgs, G as GraphQLExtension, F as FieldComplexityMap } from '../schema-builder-
|
|
2
|
-
export { h as CacheControlScope, d as DirectiveRegistration, b as EnumRegistration, a as FieldRegistration, f as GraphQLEffectContext, c as InputTypeRegistration, I as InterfaceRegistration, e as MiddlewareRegistration, O as ObjectFieldRegistration, S as SubscriptionFieldRegistration, T as TypeRegistration, g as TypeRegistries, U as UnionRegistration } from '../schema-builder-
|
|
1
|
+
import { D as DirectiveApplication, C as CacheHint, o as FieldComplexity, i as GraphQLSchemaBuilder, M as MiddlewareContext, K as ExecutionArgs, G as GraphQLExtension, F as FieldComplexityMap } from '../schema-builder-CAij36fD.js';
|
|
2
|
+
export { h as CacheControlScope, d as DirectiveRegistration, b as EnumRegistration, a as FieldRegistration, f as GraphQLEffectContext, c as InputTypeRegistration, I as InterfaceRegistration, e as MiddlewareRegistration, O as ObjectFieldRegistration, S as SubscriptionFieldRegistration, T as TypeRegistration, g as TypeRegistries, U as UnionRegistration } from '../schema-builder-CAij36fD.js';
|
|
3
3
|
import { DirectiveLocation, GraphQLResolveInfo, DocumentNode, GraphQLError, ExecutionResult, GraphQLSchema } from 'graphql';
|
|
4
4
|
export { DirectiveLocation } from 'graphql';
|
|
5
5
|
import { Effect, Stream, Layer } from 'effect';
|
package/builder/index.js
CHANGED
|
@@ -700,26 +700,56 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
700
700
|
if (memberAst._tag === "UndefinedKeyword") continue;
|
|
701
701
|
const inputName = cache?.astToInputName?.get(memberAst);
|
|
702
702
|
if (inputName) {
|
|
703
|
-
const
|
|
704
|
-
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
|
+
}
|
|
705
714
|
}
|
|
706
|
-
for (const [
|
|
715
|
+
for (const [, inputReg] of inputs) {
|
|
707
716
|
if (inputReg.schema.ast === memberAst) {
|
|
708
|
-
|
|
709
|
-
|
|
717
|
+
return toGraphQLInputTypeWithRegistry(
|
|
718
|
+
inputReg.schema,
|
|
719
|
+
enumRegistry,
|
|
720
|
+
inputRegistry,
|
|
721
|
+
inputs,
|
|
722
|
+
enums,
|
|
723
|
+
cache
|
|
724
|
+
);
|
|
710
725
|
}
|
|
711
726
|
}
|
|
712
727
|
if (memberAst._tag === "Transformation") {
|
|
713
728
|
const innerToAst = memberAst.to;
|
|
714
729
|
const transformedInputName = cache?.astToInputName?.get(innerToAst);
|
|
715
730
|
if (transformedInputName) {
|
|
716
|
-
const
|
|
717
|
-
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
|
+
}
|
|
718
742
|
}
|
|
719
|
-
for (const [
|
|
743
|
+
for (const [, inputReg] of inputs) {
|
|
720
744
|
if (inputReg.schema.ast === innerToAst) {
|
|
721
|
-
|
|
722
|
-
|
|
745
|
+
return toGraphQLInputTypeWithRegistry(
|
|
746
|
+
inputReg.schema,
|
|
747
|
+
enumRegistry,
|
|
748
|
+
inputRegistry,
|
|
749
|
+
inputs,
|
|
750
|
+
enums,
|
|
751
|
+
cache
|
|
752
|
+
);
|
|
723
753
|
}
|
|
724
754
|
}
|
|
725
755
|
}
|
|
@@ -731,25 +761,52 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
731
761
|
const valueType = valueField.type;
|
|
732
762
|
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
733
763
|
if (valueInputName) {
|
|
734
|
-
const
|
|
735
|
-
if (
|
|
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
|
+
}
|
|
736
775
|
}
|
|
737
|
-
for (const [
|
|
776
|
+
for (const [, inputReg] of inputs) {
|
|
738
777
|
if (inputReg.schema.ast === valueType) {
|
|
739
|
-
|
|
740
|
-
|
|
778
|
+
return toGraphQLInputTypeWithRegistry(
|
|
779
|
+
inputReg.schema,
|
|
780
|
+
enumRegistry,
|
|
781
|
+
inputRegistry,
|
|
782
|
+
inputs,
|
|
783
|
+
enums,
|
|
784
|
+
cache
|
|
785
|
+
);
|
|
741
786
|
}
|
|
742
787
|
let regAst = inputReg.schema.ast;
|
|
743
788
|
while (regAst._tag === "Transformation") {
|
|
744
789
|
regAst = regAst.to;
|
|
745
790
|
if (regAst === valueType) {
|
|
746
|
-
|
|
747
|
-
|
|
791
|
+
return toGraphQLInputTypeWithRegistry(
|
|
792
|
+
inputReg.schema,
|
|
793
|
+
enumRegistry,
|
|
794
|
+
inputRegistry,
|
|
795
|
+
inputs,
|
|
796
|
+
enums,
|
|
797
|
+
cache
|
|
798
|
+
);
|
|
748
799
|
}
|
|
749
800
|
}
|
|
750
801
|
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
751
|
-
|
|
752
|
-
|
|
802
|
+
return toGraphQLInputTypeWithRegistry(
|
|
803
|
+
inputReg.schema,
|
|
804
|
+
enumRegistry,
|
|
805
|
+
inputRegistry,
|
|
806
|
+
inputs,
|
|
807
|
+
enums,
|
|
808
|
+
cache
|
|
809
|
+
);
|
|
753
810
|
}
|
|
754
811
|
}
|
|
755
812
|
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
@@ -802,26 +859,56 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
802
859
|
for (const memberAst of unionAst.types) {
|
|
803
860
|
const inputName = cache?.astToInputName?.get(memberAst);
|
|
804
861
|
if (inputName) {
|
|
805
|
-
const
|
|
806
|
-
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
|
+
}
|
|
807
873
|
}
|
|
808
|
-
for (const [
|
|
874
|
+
for (const [, inputReg] of inputs) {
|
|
809
875
|
if (inputReg.schema.ast === memberAst) {
|
|
810
|
-
|
|
811
|
-
|
|
876
|
+
return toGraphQLInputTypeWithRegistry(
|
|
877
|
+
inputReg.schema,
|
|
878
|
+
enumRegistry,
|
|
879
|
+
inputRegistry,
|
|
880
|
+
inputs,
|
|
881
|
+
enums,
|
|
882
|
+
cache
|
|
883
|
+
);
|
|
812
884
|
}
|
|
813
885
|
}
|
|
814
886
|
if (memberAst._tag === "Transformation") {
|
|
815
887
|
const toAst = memberAst.to;
|
|
816
888
|
const transformedInputName = cache?.astToInputName?.get(toAst);
|
|
817
889
|
if (transformedInputName) {
|
|
818
|
-
const
|
|
819
|
-
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
|
+
}
|
|
820
901
|
}
|
|
821
|
-
for (const [
|
|
902
|
+
for (const [, inputReg] of inputs) {
|
|
822
903
|
if (inputReg.schema.ast === toAst) {
|
|
823
|
-
|
|
824
|
-
|
|
904
|
+
return toGraphQLInputTypeWithRegistry(
|
|
905
|
+
inputReg.schema,
|
|
906
|
+
enumRegistry,
|
|
907
|
+
inputRegistry,
|
|
908
|
+
inputs,
|
|
909
|
+
enums,
|
|
910
|
+
cache
|
|
911
|
+
);
|
|
825
912
|
}
|
|
826
913
|
}
|
|
827
914
|
}
|
|
@@ -833,25 +920,52 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
833
920
|
const valueType = valueField.type;
|
|
834
921
|
const valueInputName = cache?.astToInputName?.get(valueType);
|
|
835
922
|
if (valueInputName) {
|
|
836
|
-
const
|
|
837
|
-
if (
|
|
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
|
+
}
|
|
838
934
|
}
|
|
839
|
-
for (const [
|
|
935
|
+
for (const [, inputReg] of inputs) {
|
|
840
936
|
if (inputReg.schema.ast === valueType) {
|
|
841
|
-
|
|
842
|
-
|
|
937
|
+
return toGraphQLInputTypeWithRegistry(
|
|
938
|
+
inputReg.schema,
|
|
939
|
+
enumRegistry,
|
|
940
|
+
inputRegistry,
|
|
941
|
+
inputs,
|
|
942
|
+
enums,
|
|
943
|
+
cache
|
|
944
|
+
);
|
|
843
945
|
}
|
|
844
946
|
let regAst = inputReg.schema.ast;
|
|
845
947
|
while (regAst._tag === "Transformation") {
|
|
846
948
|
regAst = regAst.to;
|
|
847
949
|
if (regAst === valueType) {
|
|
848
|
-
|
|
849
|
-
|
|
950
|
+
return toGraphQLInputTypeWithRegistry(
|
|
951
|
+
inputReg.schema,
|
|
952
|
+
enumRegistry,
|
|
953
|
+
inputRegistry,
|
|
954
|
+
inputs,
|
|
955
|
+
enums,
|
|
956
|
+
cache
|
|
957
|
+
);
|
|
850
958
|
}
|
|
851
959
|
}
|
|
852
960
|
if (regAst._tag === "Declaration" && regAst.typeParameters?.[0] === valueType) {
|
|
853
|
-
|
|
854
|
-
|
|
961
|
+
return toGraphQLInputTypeWithRegistry(
|
|
962
|
+
inputReg.schema,
|
|
963
|
+
enumRegistry,
|
|
964
|
+
inputRegistry,
|
|
965
|
+
inputs,
|
|
966
|
+
enums,
|
|
967
|
+
cache
|
|
968
|
+
);
|
|
855
969
|
}
|
|
856
970
|
}
|
|
857
971
|
const innerResult = toGraphQLInputTypeWithRegistry(
|
|
@@ -1466,15 +1580,25 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1466
1580
|
}
|
|
1467
1581
|
/**
|
|
1468
1582
|
* Build the GraphQL schema (no services required)
|
|
1583
|
+
*
|
|
1584
|
+
* Uses a two-phase approach:
|
|
1585
|
+
* 1. Phase 1: Build enum and input registries first (these may be referenced by other types)
|
|
1586
|
+
* 2. Phase 2: Build interface, object, and union types (which may reference inputs in args)
|
|
1587
|
+
*
|
|
1588
|
+
* This ensures that when object type fields with args are processed,
|
|
1589
|
+
* all registered input types are already available in the inputRegistry.
|
|
1469
1590
|
*/
|
|
1470
1591
|
buildSchema() {
|
|
1471
|
-
const directiveRegistry = this.buildDirectiveRegistry();
|
|
1472
1592
|
const enumRegistry = this.buildEnumRegistry();
|
|
1473
1593
|
const inputRegistry = this.buildInputRegistry(enumRegistry);
|
|
1474
|
-
const
|
|
1594
|
+
const inputTypeLookupCache = buildInputTypeLookupCache(this.state.inputs, this.state.enums);
|
|
1595
|
+
const directiveRegistry = this.buildDirectiveRegistry(enumRegistry, inputRegistry, inputTypeLookupCache);
|
|
1596
|
+
const interfaceRegistry = this.buildInterfaceRegistry(enumRegistry, inputRegistry, inputTypeLookupCache);
|
|
1475
1597
|
const { typeRegistry, unionRegistry } = this.buildTypeAndUnionRegistries(
|
|
1476
1598
|
enumRegistry,
|
|
1477
|
-
interfaceRegistry
|
|
1599
|
+
interfaceRegistry,
|
|
1600
|
+
inputRegistry,
|
|
1601
|
+
inputTypeLookupCache
|
|
1478
1602
|
);
|
|
1479
1603
|
const fieldCtx = this.createFieldBuilderContext(
|
|
1480
1604
|
typeRegistry,
|
|
@@ -1498,9 +1622,8 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1498
1622
|
subscriptionFields
|
|
1499
1623
|
});
|
|
1500
1624
|
}
|
|
1501
|
-
buildDirectiveRegistry() {
|
|
1625
|
+
buildDirectiveRegistry(enumRegistry, inputRegistry, cache) {
|
|
1502
1626
|
const registry = /* @__PURE__ */ new Map();
|
|
1503
|
-
const cache = buildInputTypeLookupCache(this.state.inputs, this.state.enums);
|
|
1504
1627
|
for (const [name, reg] of this.state.directives) {
|
|
1505
1628
|
const graphqlDirective = new GraphQLDirective({
|
|
1506
1629
|
name,
|
|
@@ -1508,8 +1631,8 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1508
1631
|
locations: [...reg.locations],
|
|
1509
1632
|
args: reg.args ? toGraphQLArgsWithRegistry(
|
|
1510
1633
|
reg.args,
|
|
1511
|
-
|
|
1512
|
-
|
|
1634
|
+
enumRegistry,
|
|
1635
|
+
inputRegistry,
|
|
1513
1636
|
this.state.inputs,
|
|
1514
1637
|
this.state.enums,
|
|
1515
1638
|
cache
|
|
@@ -1559,7 +1682,7 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1559
1682
|
}
|
|
1560
1683
|
return registry;
|
|
1561
1684
|
}
|
|
1562
|
-
buildInterfaceRegistry(enumRegistry) {
|
|
1685
|
+
buildInterfaceRegistry(enumRegistry, inputRegistry, _cache) {
|
|
1563
1686
|
const registry = /* @__PURE__ */ new Map();
|
|
1564
1687
|
const typeRegistry = /* @__PURE__ */ new Map();
|
|
1565
1688
|
const unionRegistry = /* @__PURE__ */ new Map();
|
|
@@ -1585,7 +1708,7 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1585
1708
|
}
|
|
1586
1709
|
return registry;
|
|
1587
1710
|
}
|
|
1588
|
-
buildTypeAndUnionRegistries(enumRegistry, interfaceRegistry) {
|
|
1711
|
+
buildTypeAndUnionRegistries(enumRegistry, interfaceRegistry, inputRegistry, inputTypeLookupCache) {
|
|
1589
1712
|
const typeRegistry = /* @__PURE__ */ new Map();
|
|
1590
1713
|
const unionRegistry = /* @__PURE__ */ new Map();
|
|
1591
1714
|
const sharedCtx = {
|
|
@@ -1594,18 +1717,19 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1594
1717
|
enums: this.state.enums,
|
|
1595
1718
|
unions: this.state.unions,
|
|
1596
1719
|
inputs: this.state.inputs,
|
|
1597
|
-
typeRegistry,
|
|
1598
|
-
interfaceRegistry,
|
|
1599
|
-
enumRegistry,
|
|
1600
|
-
unionRegistry};
|
|
1601
|
-
buildReverseLookups(sharedCtx);
|
|
1602
|
-
const sharedFieldCtx = this.createFieldBuilderContext(
|
|
1603
1720
|
typeRegistry,
|
|
1604
1721
|
interfaceRegistry,
|
|
1605
1722
|
enumRegistry,
|
|
1606
1723
|
unionRegistry,
|
|
1607
|
-
|
|
1608
|
-
|
|
1724
|
+
inputRegistry
|
|
1725
|
+
};
|
|
1726
|
+
buildReverseLookups(sharedCtx);
|
|
1727
|
+
const sharedFieldCtx = {
|
|
1728
|
+
...sharedCtx,
|
|
1729
|
+
directiveRegistrations: this.state.directives,
|
|
1730
|
+
middlewares: this.state.middlewares,
|
|
1731
|
+
inputTypeLookupCache
|
|
1732
|
+
};
|
|
1609
1733
|
for (const [typeName, typeReg] of this.state.types) {
|
|
1610
1734
|
const implementedInterfaces = typeReg.implements?.map((name) => interfaceRegistry.get(name)).filter(Boolean) ?? [];
|
|
1611
1735
|
const graphqlType = new GraphQLObjectType({
|