@effect-gql/core 1.4.6 → 1.4.8
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 +42 -21
- 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 +42 -21
- package/builder/index.js.map +1 -1
- package/index.cjs +44 -22
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -2
- package/index.d.ts +2 -2
- package/index.js +44 -22
- 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
|
@@ -11,7 +11,15 @@ var isIntegerType = (ast) => {
|
|
|
11
11
|
const annotations = refinement.annotations;
|
|
12
12
|
if (annotations) {
|
|
13
13
|
const identifier = AST.getIdentifierAnnotation(refinement);
|
|
14
|
-
if (identifier._tag === "Some"
|
|
14
|
+
if (identifier._tag === "Some") {
|
|
15
|
+
const id = identifier.value;
|
|
16
|
+
if (id === "Int" || id.includes("Int")) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const JSONSchemaSymbol = /* @__PURE__ */ Symbol.for("effect/annotation/JSONSchema");
|
|
21
|
+
const jsonSchema = annotations[JSONSchemaSymbol];
|
|
22
|
+
if (jsonSchema && jsonSchema.type === "integer") {
|
|
15
23
|
return true;
|
|
16
24
|
}
|
|
17
25
|
}
|
|
@@ -79,7 +87,8 @@ var toGraphQLType = (schema) => {
|
|
|
79
87
|
if (fieldName === "_tag") continue;
|
|
80
88
|
const fieldSchema = S2.make(field2.type);
|
|
81
89
|
let fieldType = toGraphQLType(fieldSchema);
|
|
82
|
-
|
|
90
|
+
const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
|
|
91
|
+
if (!field2.isOptional && !isOptionField) {
|
|
83
92
|
fieldType = new GraphQLNonNull(fieldType);
|
|
84
93
|
}
|
|
85
94
|
fields[fieldName] = { type: fieldType };
|
|
@@ -155,7 +164,8 @@ var toGraphQLInputType = (schema) => {
|
|
|
155
164
|
if (fieldName === "_tag") continue;
|
|
156
165
|
const fieldSchema = S2.make(field2.type);
|
|
157
166
|
let fieldType = toGraphQLInputType(fieldSchema);
|
|
158
|
-
|
|
167
|
+
const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
|
|
168
|
+
if (!field2.isOptional && !isOptionField) {
|
|
159
169
|
fieldType = new GraphQLNonNull(fieldType);
|
|
160
170
|
}
|
|
161
171
|
fields[fieldName] = { type: fieldType };
|
|
@@ -206,7 +216,8 @@ var toGraphQLArgs = (schema) => {
|
|
|
206
216
|
if (fieldName === "_tag") continue;
|
|
207
217
|
const fieldSchema = S2.make(field2.type);
|
|
208
218
|
let fieldType = toGraphQLInputType(fieldSchema);
|
|
209
|
-
|
|
219
|
+
const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
|
|
220
|
+
if (!field2.isOptional && !isOptionField) {
|
|
210
221
|
fieldType = new GraphQLNonNull(fieldType);
|
|
211
222
|
}
|
|
212
223
|
args[fieldName] = { type: fieldType };
|
|
@@ -1580,15 +1591,25 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1580
1591
|
}
|
|
1581
1592
|
/**
|
|
1582
1593
|
* Build the GraphQL schema (no services required)
|
|
1594
|
+
*
|
|
1595
|
+
* Uses a two-phase approach:
|
|
1596
|
+
* 1. Phase 1: Build enum and input registries first (these may be referenced by other types)
|
|
1597
|
+
* 2. Phase 2: Build interface, object, and union types (which may reference inputs in args)
|
|
1598
|
+
*
|
|
1599
|
+
* This ensures that when object type fields with args are processed,
|
|
1600
|
+
* all registered input types are already available in the inputRegistry.
|
|
1583
1601
|
*/
|
|
1584
1602
|
buildSchema() {
|
|
1585
|
-
const directiveRegistry = this.buildDirectiveRegistry();
|
|
1586
1603
|
const enumRegistry = this.buildEnumRegistry();
|
|
1587
1604
|
const inputRegistry = this.buildInputRegistry(enumRegistry);
|
|
1588
|
-
const
|
|
1605
|
+
const inputTypeLookupCache = buildInputTypeLookupCache(this.state.inputs, this.state.enums);
|
|
1606
|
+
const directiveRegistry = this.buildDirectiveRegistry(enumRegistry, inputRegistry, inputTypeLookupCache);
|
|
1607
|
+
const interfaceRegistry = this.buildInterfaceRegistry(enumRegistry, inputRegistry, inputTypeLookupCache);
|
|
1589
1608
|
const { typeRegistry, unionRegistry } = this.buildTypeAndUnionRegistries(
|
|
1590
1609
|
enumRegistry,
|
|
1591
|
-
interfaceRegistry
|
|
1610
|
+
interfaceRegistry,
|
|
1611
|
+
inputRegistry,
|
|
1612
|
+
inputTypeLookupCache
|
|
1592
1613
|
);
|
|
1593
1614
|
const fieldCtx = this.createFieldBuilderContext(
|
|
1594
1615
|
typeRegistry,
|
|
@@ -1612,9 +1633,8 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1612
1633
|
subscriptionFields
|
|
1613
1634
|
});
|
|
1614
1635
|
}
|
|
1615
|
-
buildDirectiveRegistry() {
|
|
1636
|
+
buildDirectiveRegistry(enumRegistry, inputRegistry, cache) {
|
|
1616
1637
|
const registry = /* @__PURE__ */ new Map();
|
|
1617
|
-
const cache = buildInputTypeLookupCache(this.state.inputs, this.state.enums);
|
|
1618
1638
|
for (const [name, reg] of this.state.directives) {
|
|
1619
1639
|
const graphqlDirective = new GraphQLDirective({
|
|
1620
1640
|
name,
|
|
@@ -1622,8 +1642,8 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1622
1642
|
locations: [...reg.locations],
|
|
1623
1643
|
args: reg.args ? toGraphQLArgsWithRegistry(
|
|
1624
1644
|
reg.args,
|
|
1625
|
-
|
|
1626
|
-
|
|
1645
|
+
enumRegistry,
|
|
1646
|
+
inputRegistry,
|
|
1627
1647
|
this.state.inputs,
|
|
1628
1648
|
this.state.enums,
|
|
1629
1649
|
cache
|
|
@@ -1673,7 +1693,7 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1673
1693
|
}
|
|
1674
1694
|
return registry;
|
|
1675
1695
|
}
|
|
1676
|
-
buildInterfaceRegistry(enumRegistry) {
|
|
1696
|
+
buildInterfaceRegistry(enumRegistry, inputRegistry, _cache) {
|
|
1677
1697
|
const registry = /* @__PURE__ */ new Map();
|
|
1678
1698
|
const typeRegistry = /* @__PURE__ */ new Map();
|
|
1679
1699
|
const unionRegistry = /* @__PURE__ */ new Map();
|
|
@@ -1699,7 +1719,7 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1699
1719
|
}
|
|
1700
1720
|
return registry;
|
|
1701
1721
|
}
|
|
1702
|
-
buildTypeAndUnionRegistries(enumRegistry, interfaceRegistry) {
|
|
1722
|
+
buildTypeAndUnionRegistries(enumRegistry, interfaceRegistry, inputRegistry, inputTypeLookupCache) {
|
|
1703
1723
|
const typeRegistry = /* @__PURE__ */ new Map();
|
|
1704
1724
|
const unionRegistry = /* @__PURE__ */ new Map();
|
|
1705
1725
|
const sharedCtx = {
|
|
@@ -1708,18 +1728,19 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1708
1728
|
enums: this.state.enums,
|
|
1709
1729
|
unions: this.state.unions,
|
|
1710
1730
|
inputs: this.state.inputs,
|
|
1711
|
-
typeRegistry,
|
|
1712
|
-
interfaceRegistry,
|
|
1713
|
-
enumRegistry,
|
|
1714
|
-
unionRegistry};
|
|
1715
|
-
buildReverseLookups(sharedCtx);
|
|
1716
|
-
const sharedFieldCtx = this.createFieldBuilderContext(
|
|
1717
1731
|
typeRegistry,
|
|
1718
1732
|
interfaceRegistry,
|
|
1719
1733
|
enumRegistry,
|
|
1720
1734
|
unionRegistry,
|
|
1721
|
-
|
|
1722
|
-
|
|
1735
|
+
inputRegistry
|
|
1736
|
+
};
|
|
1737
|
+
buildReverseLookups(sharedCtx);
|
|
1738
|
+
const sharedFieldCtx = {
|
|
1739
|
+
...sharedCtx,
|
|
1740
|
+
directiveRegistrations: this.state.directives,
|
|
1741
|
+
middlewares: this.state.middlewares,
|
|
1742
|
+
inputTypeLookupCache
|
|
1743
|
+
};
|
|
1723
1744
|
for (const [typeName, typeReg] of this.state.types) {
|
|
1724
1745
|
const implementedInterfaces = typeReg.implements?.map((name) => interfaceRegistry.get(name)).filter(Boolean) ?? [];
|
|
1725
1746
|
const graphqlType = new GraphQLObjectType({
|