@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/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FieldComplexityMap, G as GraphQLExtension, E as ExtensionsService } from './schema-builder-
|
|
2
|
-
export { y as CacheControlConfig, J as CacheControlConfigFromEnv, h as CacheControlScope, C as CacheHint, w as CacheHintMap, x as CachePolicy, z as CachePolicyAnalysisInfo, q as ComplexityAnalysisError, l as ComplexityAnalysisInfo, n as ComplexityCalculator, j as ComplexityConfig, u as ComplexityConfigFromEnv, m as ComplexityExceededInfo, p as ComplexityLimitExceededError, k as ComplexityResult, D as DirectiveApplication, d as DirectiveRegistration, b as EnumRegistration, K as ExecutionArgs, o as FieldComplexity, a as FieldRegistration, f as GraphQLEffectContext, i as GraphQLSchemaBuilder, c as InputTypeRegistration, I as InterfaceRegistration, M as MiddlewareContext, e as MiddlewareRegistration, O as ObjectFieldRegistration, S as SubscriptionFieldRegistration, T as TypeRegistration, g as TypeRegistries, U as UnionRegistration, t as combineCalculators, A as computeCachePolicy, B as computeCachePolicyFromQuery, r as defaultComplexityCalculator, s as depthOnlyCalculator, L as makeExtensionsService, R as runExecuteEndHooks, Q as runExecuteStartHooks, N as runParseHooks, P as runValidateHooks, H as toCacheControlHeader, v as validateComplexity } from './schema-builder-
|
|
1
|
+
import { F as FieldComplexityMap, G as GraphQLExtension, E as ExtensionsService } from './schema-builder-CAij36fD.cjs';
|
|
2
|
+
export { y as CacheControlConfig, J as CacheControlConfigFromEnv, h as CacheControlScope, C as CacheHint, w as CacheHintMap, x as CachePolicy, z as CachePolicyAnalysisInfo, q as ComplexityAnalysisError, l as ComplexityAnalysisInfo, n as ComplexityCalculator, j as ComplexityConfig, u as ComplexityConfigFromEnv, m as ComplexityExceededInfo, p as ComplexityLimitExceededError, k as ComplexityResult, D as DirectiveApplication, d as DirectiveRegistration, b as EnumRegistration, K as ExecutionArgs, o as FieldComplexity, a as FieldRegistration, f as GraphQLEffectContext, i as GraphQLSchemaBuilder, c as InputTypeRegistration, I as InterfaceRegistration, M as MiddlewareContext, e as MiddlewareRegistration, O as ObjectFieldRegistration, S as SubscriptionFieldRegistration, T as TypeRegistration, g as TypeRegistries, U as UnionRegistration, t as combineCalculators, A as computeCachePolicy, B as computeCachePolicyFromQuery, r as defaultComplexityCalculator, s as depthOnlyCalculator, L as makeExtensionsService, R as runExecuteEndHooks, Q as runExecuteStartHooks, N as runParseHooks, P as runValidateHooks, H as toCacheControlHeader, v as validateComplexity } from './schema-builder-CAij36fD.cjs';
|
|
3
3
|
import { GraphQLOutputType, GraphQLInputType, GraphQLFieldConfigArgumentMap, GraphQLObjectType } from 'graphql';
|
|
4
4
|
export { DirectiveLocation, GraphQLBoolean, GraphQLEnumType, GraphQLFieldConfigMap, GraphQLFloat, GraphQLID, GraphQLInputObjectType, GraphQLInt, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, GraphQLSchema, GraphQLString, GraphQLUnionType, Kind, ValueNode, graphql, lexicographicSortSchema, printSchema } from 'graphql';
|
|
5
5
|
export { compose, directive, enumType, execute, extension, field, getSchemaName, inputType, interfaceType, middleware, mutation, objectType, query, subscription, unionType } from './builder/index.cjs';
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FieldComplexityMap, G as GraphQLExtension, E as ExtensionsService } from './schema-builder-
|
|
2
|
-
export { y as CacheControlConfig, J as CacheControlConfigFromEnv, h as CacheControlScope, C as CacheHint, w as CacheHintMap, x as CachePolicy, z as CachePolicyAnalysisInfo, q as ComplexityAnalysisError, l as ComplexityAnalysisInfo, n as ComplexityCalculator, j as ComplexityConfig, u as ComplexityConfigFromEnv, m as ComplexityExceededInfo, p as ComplexityLimitExceededError, k as ComplexityResult, D as DirectiveApplication, d as DirectiveRegistration, b as EnumRegistration, K as ExecutionArgs, o as FieldComplexity, a as FieldRegistration, f as GraphQLEffectContext, i as GraphQLSchemaBuilder, c as InputTypeRegistration, I as InterfaceRegistration, M as MiddlewareContext, e as MiddlewareRegistration, O as ObjectFieldRegistration, S as SubscriptionFieldRegistration, T as TypeRegistration, g as TypeRegistries, U as UnionRegistration, t as combineCalculators, A as computeCachePolicy, B as computeCachePolicyFromQuery, r as defaultComplexityCalculator, s as depthOnlyCalculator, L as makeExtensionsService, R as runExecuteEndHooks, Q as runExecuteStartHooks, N as runParseHooks, P as runValidateHooks, H as toCacheControlHeader, v as validateComplexity } from './schema-builder-
|
|
1
|
+
import { F as FieldComplexityMap, G as GraphQLExtension, E as ExtensionsService } from './schema-builder-CAij36fD.js';
|
|
2
|
+
export { y as CacheControlConfig, J as CacheControlConfigFromEnv, h as CacheControlScope, C as CacheHint, w as CacheHintMap, x as CachePolicy, z as CachePolicyAnalysisInfo, q as ComplexityAnalysisError, l as ComplexityAnalysisInfo, n as ComplexityCalculator, j as ComplexityConfig, u as ComplexityConfigFromEnv, m as ComplexityExceededInfo, p as ComplexityLimitExceededError, k as ComplexityResult, D as DirectiveApplication, d as DirectiveRegistration, b as EnumRegistration, K as ExecutionArgs, o as FieldComplexity, a as FieldRegistration, f as GraphQLEffectContext, i as GraphQLSchemaBuilder, c as InputTypeRegistration, I as InterfaceRegistration, M as MiddlewareContext, e as MiddlewareRegistration, O as ObjectFieldRegistration, S as SubscriptionFieldRegistration, T as TypeRegistration, g as TypeRegistries, U as UnionRegistration, t as combineCalculators, A as computeCachePolicy, B as computeCachePolicyFromQuery, r as defaultComplexityCalculator, s as depthOnlyCalculator, L as makeExtensionsService, R as runExecuteEndHooks, Q as runExecuteStartHooks, N as runParseHooks, P as runValidateHooks, H as toCacheControlHeader, v as validateComplexity } from './schema-builder-CAij36fD.js';
|
|
3
3
|
import { GraphQLOutputType, GraphQLInputType, GraphQLFieldConfigArgumentMap, GraphQLObjectType } from 'graphql';
|
|
4
4
|
export { DirectiveLocation, GraphQLBoolean, GraphQLEnumType, GraphQLFieldConfigMap, GraphQLFloat, GraphQLID, GraphQLInputObjectType, GraphQLInt, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, GraphQLSchema, GraphQLString, GraphQLUnionType, Kind, ValueNode, graphql, lexicographicSortSchema, printSchema } from 'graphql';
|
|
5
5
|
export { compose, directive, enumType, execute, extension, field, getSchemaName, inputType, interfaceType, middleware, mutation, objectType, query, subscription, unionType } from './builder/index.js';
|
package/index.js
CHANGED
|
@@ -13,7 +13,15 @@ var isIntegerType = (ast) => {
|
|
|
13
13
|
const annotations = refinement.annotations;
|
|
14
14
|
if (annotations) {
|
|
15
15
|
const identifier = AST.getIdentifierAnnotation(refinement);
|
|
16
|
-
if (identifier._tag === "Some"
|
|
16
|
+
if (identifier._tag === "Some") {
|
|
17
|
+
const id = identifier.value;
|
|
18
|
+
if (id === "Int" || id.includes("Int")) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const JSONSchemaSymbol = /* @__PURE__ */ Symbol.for("effect/annotation/JSONSchema");
|
|
23
|
+
const jsonSchema = annotations[JSONSchemaSymbol];
|
|
24
|
+
if (jsonSchema && jsonSchema.type === "integer") {
|
|
17
25
|
return true;
|
|
18
26
|
}
|
|
19
27
|
}
|
|
@@ -81,7 +89,8 @@ var toGraphQLType = (schema) => {
|
|
|
81
89
|
if (fieldName === "_tag") continue;
|
|
82
90
|
const fieldSchema = S2.make(field2.type);
|
|
83
91
|
let fieldType = toGraphQLType(fieldSchema);
|
|
84
|
-
|
|
92
|
+
const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
|
|
93
|
+
if (!field2.isOptional && !isOptionField) {
|
|
85
94
|
fieldType = new GraphQLNonNull(fieldType);
|
|
86
95
|
}
|
|
87
96
|
fields[fieldName] = { type: fieldType };
|
|
@@ -157,7 +166,8 @@ var toGraphQLInputType = (schema) => {
|
|
|
157
166
|
if (fieldName === "_tag") continue;
|
|
158
167
|
const fieldSchema = S2.make(field2.type);
|
|
159
168
|
let fieldType = toGraphQLInputType(fieldSchema);
|
|
160
|
-
|
|
169
|
+
const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
|
|
170
|
+
if (!field2.isOptional && !isOptionField) {
|
|
161
171
|
fieldType = new GraphQLNonNull(fieldType);
|
|
162
172
|
}
|
|
163
173
|
fields[fieldName] = { type: fieldType };
|
|
@@ -220,7 +230,8 @@ var toGraphQLObjectType = (name, schema, additionalFields) => {
|
|
|
220
230
|
if (fieldName === "_tag") continue;
|
|
221
231
|
const fieldSchema = S2.make(field2.type);
|
|
222
232
|
let fieldType = toGraphQLType(fieldSchema);
|
|
223
|
-
|
|
233
|
+
const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
|
|
234
|
+
if (!field2.isOptional && !isOptionField) {
|
|
224
235
|
fieldType = new GraphQLNonNull(fieldType);
|
|
225
236
|
}
|
|
226
237
|
fields[fieldName] = { type: fieldType };
|
|
@@ -252,7 +263,8 @@ var toGraphQLArgs = (schema) => {
|
|
|
252
263
|
if (fieldName === "_tag") continue;
|
|
253
264
|
const fieldSchema = S2.make(field2.type);
|
|
254
265
|
let fieldType = toGraphQLInputType(fieldSchema);
|
|
255
|
-
|
|
266
|
+
const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
|
|
267
|
+
if (!field2.isOptional && !isOptionField) {
|
|
256
268
|
fieldType = new GraphQLNonNull(fieldType);
|
|
257
269
|
}
|
|
258
270
|
args[fieldName] = { type: fieldType };
|
|
@@ -1626,15 +1638,25 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1626
1638
|
}
|
|
1627
1639
|
/**
|
|
1628
1640
|
* Build the GraphQL schema (no services required)
|
|
1641
|
+
*
|
|
1642
|
+
* Uses a two-phase approach:
|
|
1643
|
+
* 1. Phase 1: Build enum and input registries first (these may be referenced by other types)
|
|
1644
|
+
* 2. Phase 2: Build interface, object, and union types (which may reference inputs in args)
|
|
1645
|
+
*
|
|
1646
|
+
* This ensures that when object type fields with args are processed,
|
|
1647
|
+
* all registered input types are already available in the inputRegistry.
|
|
1629
1648
|
*/
|
|
1630
1649
|
buildSchema() {
|
|
1631
|
-
const directiveRegistry = this.buildDirectiveRegistry();
|
|
1632
1650
|
const enumRegistry = this.buildEnumRegistry();
|
|
1633
1651
|
const inputRegistry = this.buildInputRegistry(enumRegistry);
|
|
1634
|
-
const
|
|
1652
|
+
const inputTypeLookupCache = buildInputTypeLookupCache(this.state.inputs, this.state.enums);
|
|
1653
|
+
const directiveRegistry = this.buildDirectiveRegistry(enumRegistry, inputRegistry, inputTypeLookupCache);
|
|
1654
|
+
const interfaceRegistry = this.buildInterfaceRegistry(enumRegistry, inputRegistry, inputTypeLookupCache);
|
|
1635
1655
|
const { typeRegistry, unionRegistry } = this.buildTypeAndUnionRegistries(
|
|
1636
1656
|
enumRegistry,
|
|
1637
|
-
interfaceRegistry
|
|
1657
|
+
interfaceRegistry,
|
|
1658
|
+
inputRegistry,
|
|
1659
|
+
inputTypeLookupCache
|
|
1638
1660
|
);
|
|
1639
1661
|
const fieldCtx = this.createFieldBuilderContext(
|
|
1640
1662
|
typeRegistry,
|
|
@@ -1658,9 +1680,8 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1658
1680
|
subscriptionFields
|
|
1659
1681
|
});
|
|
1660
1682
|
}
|
|
1661
|
-
buildDirectiveRegistry() {
|
|
1683
|
+
buildDirectiveRegistry(enumRegistry, inputRegistry, cache) {
|
|
1662
1684
|
const registry = /* @__PURE__ */ new Map();
|
|
1663
|
-
const cache = buildInputTypeLookupCache(this.state.inputs, this.state.enums);
|
|
1664
1685
|
for (const [name, reg] of this.state.directives) {
|
|
1665
1686
|
const graphqlDirective = new GraphQLDirective({
|
|
1666
1687
|
name,
|
|
@@ -1668,8 +1689,8 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1668
1689
|
locations: [...reg.locations],
|
|
1669
1690
|
args: reg.args ? toGraphQLArgsWithRegistry(
|
|
1670
1691
|
reg.args,
|
|
1671
|
-
|
|
1672
|
-
|
|
1692
|
+
enumRegistry,
|
|
1693
|
+
inputRegistry,
|
|
1673
1694
|
this.state.inputs,
|
|
1674
1695
|
this.state.enums,
|
|
1675
1696
|
cache
|
|
@@ -1719,7 +1740,7 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1719
1740
|
}
|
|
1720
1741
|
return registry;
|
|
1721
1742
|
}
|
|
1722
|
-
buildInterfaceRegistry(enumRegistry) {
|
|
1743
|
+
buildInterfaceRegistry(enumRegistry, inputRegistry, _cache) {
|
|
1723
1744
|
const registry = /* @__PURE__ */ new Map();
|
|
1724
1745
|
const typeRegistry = /* @__PURE__ */ new Map();
|
|
1725
1746
|
const unionRegistry = /* @__PURE__ */ new Map();
|
|
@@ -1745,7 +1766,7 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1745
1766
|
}
|
|
1746
1767
|
return registry;
|
|
1747
1768
|
}
|
|
1748
|
-
buildTypeAndUnionRegistries(enumRegistry, interfaceRegistry) {
|
|
1769
|
+
buildTypeAndUnionRegistries(enumRegistry, interfaceRegistry, inputRegistry, inputTypeLookupCache) {
|
|
1749
1770
|
const typeRegistry = /* @__PURE__ */ new Map();
|
|
1750
1771
|
const unionRegistry = /* @__PURE__ */ new Map();
|
|
1751
1772
|
const sharedCtx = {
|
|
@@ -1754,18 +1775,19 @@ var GraphQLSchemaBuilder = class _GraphQLSchemaBuilder {
|
|
|
1754
1775
|
enums: this.state.enums,
|
|
1755
1776
|
unions: this.state.unions,
|
|
1756
1777
|
inputs: this.state.inputs,
|
|
1757
|
-
typeRegistry,
|
|
1758
|
-
interfaceRegistry,
|
|
1759
|
-
enumRegistry,
|
|
1760
|
-
unionRegistry};
|
|
1761
|
-
buildReverseLookups(sharedCtx);
|
|
1762
|
-
const sharedFieldCtx = this.createFieldBuilderContext(
|
|
1763
1778
|
typeRegistry,
|
|
1764
1779
|
interfaceRegistry,
|
|
1765
1780
|
enumRegistry,
|
|
1766
1781
|
unionRegistry,
|
|
1767
|
-
|
|
1768
|
-
|
|
1782
|
+
inputRegistry
|
|
1783
|
+
};
|
|
1784
|
+
buildReverseLookups(sharedCtx);
|
|
1785
|
+
const sharedFieldCtx = {
|
|
1786
|
+
...sharedCtx,
|
|
1787
|
+
directiveRegistrations: this.state.directives,
|
|
1788
|
+
middlewares: this.state.middlewares,
|
|
1789
|
+
inputTypeLookupCache
|
|
1790
|
+
};
|
|
1769
1791
|
for (const [typeName, typeReg] of this.state.types) {
|
|
1770
1792
|
const implementedInterfaces = typeReg.implements?.map((name) => interfaceRegistry.get(name)).filter(Boolean) ?? [];
|
|
1771
1793
|
const graphqlType = new GraphQLObjectType({
|