@effect-gql/core 1.4.6 → 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/index.cjs CHANGED
@@ -1651,15 +1651,25 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
1651
1651
  }
1652
1652
  /**
1653
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.
1654
1661
  */
1655
1662
  buildSchema() {
1656
- const directiveRegistry = this.buildDirectiveRegistry();
1657
1663
  const enumRegistry = this.buildEnumRegistry();
1658
1664
  const inputRegistry = this.buildInputRegistry(enumRegistry);
1659
- const interfaceRegistry = this.buildInterfaceRegistry(enumRegistry);
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);
1660
1668
  const { typeRegistry, unionRegistry } = this.buildTypeAndUnionRegistries(
1661
1669
  enumRegistry,
1662
- interfaceRegistry
1670
+ interfaceRegistry,
1671
+ inputRegistry,
1672
+ inputTypeLookupCache
1663
1673
  );
1664
1674
  const fieldCtx = this.createFieldBuilderContext(
1665
1675
  typeRegistry,
@@ -1683,9 +1693,8 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
1683
1693
  subscriptionFields
1684
1694
  });
1685
1695
  }
1686
- buildDirectiveRegistry() {
1696
+ buildDirectiveRegistry(enumRegistry, inputRegistry, cache) {
1687
1697
  const registry = /* @__PURE__ */ new Map();
1688
- const cache = buildInputTypeLookupCache(this.state.inputs, this.state.enums);
1689
1698
  for (const [name, reg] of this.state.directives) {
1690
1699
  const graphqlDirective = new graphql.GraphQLDirective({
1691
1700
  name,
@@ -1693,8 +1702,8 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
1693
1702
  locations: [...reg.locations],
1694
1703
  args: reg.args ? toGraphQLArgsWithRegistry(
1695
1704
  reg.args,
1696
- /* @__PURE__ */ new Map(),
1697
- /* @__PURE__ */ new Map(),
1705
+ enumRegistry,
1706
+ inputRegistry,
1698
1707
  this.state.inputs,
1699
1708
  this.state.enums,
1700
1709
  cache
@@ -1744,7 +1753,7 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
1744
1753
  }
1745
1754
  return registry;
1746
1755
  }
1747
- buildInterfaceRegistry(enumRegistry) {
1756
+ buildInterfaceRegistry(enumRegistry, inputRegistry, _cache) {
1748
1757
  const registry = /* @__PURE__ */ new Map();
1749
1758
  const typeRegistry = /* @__PURE__ */ new Map();
1750
1759
  const unionRegistry = /* @__PURE__ */ new Map();
@@ -1770,7 +1779,7 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
1770
1779
  }
1771
1780
  return registry;
1772
1781
  }
1773
- buildTypeAndUnionRegistries(enumRegistry, interfaceRegistry) {
1782
+ buildTypeAndUnionRegistries(enumRegistry, interfaceRegistry, inputRegistry, inputTypeLookupCache) {
1774
1783
  const typeRegistry = /* @__PURE__ */ new Map();
1775
1784
  const unionRegistry = /* @__PURE__ */ new Map();
1776
1785
  const sharedCtx = {
@@ -1779,18 +1788,19 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
1779
1788
  enums: this.state.enums,
1780
1789
  unions: this.state.unions,
1781
1790
  inputs: this.state.inputs,
1782
- typeRegistry,
1783
- interfaceRegistry,
1784
- enumRegistry,
1785
- unionRegistry};
1786
- buildReverseLookups(sharedCtx);
1787
- const sharedFieldCtx = this.createFieldBuilderContext(
1788
1791
  typeRegistry,
1789
1792
  interfaceRegistry,
1790
1793
  enumRegistry,
1791
1794
  unionRegistry,
1792
- /* @__PURE__ */ new Map()
1793
- );
1795
+ inputRegistry
1796
+ };
1797
+ buildReverseLookups(sharedCtx);
1798
+ const sharedFieldCtx = {
1799
+ ...sharedCtx,
1800
+ directiveRegistrations: this.state.directives,
1801
+ middlewares: this.state.middlewares,
1802
+ inputTypeLookupCache
1803
+ };
1794
1804
  for (const [typeName, typeReg] of this.state.types) {
1795
1805
  const implementedInterfaces = typeReg.implements?.map((name) => interfaceRegistry.get(name)).filter(Boolean) ?? [];
1796
1806
  const graphqlType = new graphql.GraphQLObjectType({