@effect-gql/core 1.4.9 → 1.4.11

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.d.cts CHANGED
@@ -5,12 +5,23 @@ export { DirectiveLocation, GraphQLBoolean, GraphQLEnumType, GraphQLFieldConfigM
5
5
  export { compose, directive, enumType, execute, extension, field, getSchemaName, inputType, interfaceType, middleware, mutation, objectType, query, subscription, unionType } from './builder/index.cjs';
6
6
  import { Effect, Context, Layer, Ref, HashMap, Option } from 'effect';
7
7
  import * as S from 'effect/Schema';
8
+ import * as AST from 'effect/SchemaAST';
8
9
  import * as effect_Cause from 'effect/Cause';
9
10
  import * as effect_Types from 'effect/Types';
10
11
  import DataLoader from 'dataloader';
11
12
  export { CloseEvent, CompleteMessage, ConnectionContext, EffectSSE, EffectWebSocket, ErrorHandler, GraphQLRouterConfig, GraphQLRouterConfigFromEnv, GraphQLRouterConfigInput, GraphQLSSEConfig, GraphQLSSEOptions, GraphQLWSConfig, GraphQLWSOptions, GraphiQLConfig, MakeGraphQLRouterOptions, SSEConnectionContext, SSEError, SSEEvent, SSEEventType, SSESubscriptionRequest, SSESubscriptionResult, SSE_HEADERS, SubscribeMessage, WS_CLOSED, WebSocketError, WsWebSocket, defaultConfig, defaultErrorHandler, formatCompleteEvent, formatErrorEvent, formatNextEvent, formatSSEMessage, graphiqlHtml, makeGraphQLRouter, makeGraphQLSSEHandler, makeGraphQLWSHandler, makeSSESubscriptionStream, normalizeConfig, toEffectWebSocketFromWs, toRouter } from './server/index.cjs';
12
13
  import '@effect/platform';
13
14
 
15
+ /**
16
+ * Check if a Declaration AST node represents an Option type.
17
+ * Option declarations have a TypeConstructor annotation of 'effect/Option'.
18
+ */
19
+ declare const isOptionDeclaration: (ast: AST.AST) => boolean;
20
+ /**
21
+ * Check if a Transformation represents an Option schema (e.g., S.OptionFromNullOr).
22
+ * These have a Declaration with "Option" identifier on the "to" side.
23
+ */
24
+ declare const isOptionTransformation: (ast: AST.AST) => boolean;
14
25
  /**
15
26
  * Convert an Effect Schema to a GraphQL output type
16
27
  */
@@ -526,4 +537,4 @@ interface AnalyzerOutput {
526
537
  */
527
538
  declare const createAnalyzerExtension: (config?: AnalyzerExtensionConfig) => GraphQLExtension<ExtensionsService>;
528
539
 
529
- export { type AdditionalField, type AnalyzerExtensionConfig, type AnalyzerOutput, AuthorizationError, ExtensionsService, FieldComplexityMap, GraphQLError, GraphQLExtension, GraphQLRequestContext, type GroupedLoaderDef, Loader, type LoaderDef, type LoaderInstances, LoaderRegistry, MissingResolverContextError, NotFoundError, ResolverContext, type ResolverContextSlot, ResolverContextStore, type SingleLoaderDef, ValidationError, createAnalyzerExtension, get, getOption, getOrElse, has, make, makeRequestContextLayer, makeStoreLayer, scoped, set, setMany, storeLayer, toGraphQLArgs, toGraphQLInputType, toGraphQLObjectType, toGraphQLType };
540
+ export { type AdditionalField, type AnalyzerExtensionConfig, type AnalyzerOutput, AuthorizationError, ExtensionsService, FieldComplexityMap, GraphQLError, GraphQLExtension, GraphQLRequestContext, type GroupedLoaderDef, Loader, type LoaderDef, type LoaderInstances, LoaderRegistry, MissingResolverContextError, NotFoundError, ResolverContext, type ResolverContextSlot, ResolverContextStore, type SingleLoaderDef, ValidationError, createAnalyzerExtension, get, getOption, getOrElse, has, isOptionDeclaration, isOptionTransformation, make, makeRequestContextLayer, makeStoreLayer, scoped, set, setMany, storeLayer, toGraphQLArgs, toGraphQLInputType, toGraphQLObjectType, toGraphQLType };
package/index.d.ts CHANGED
@@ -5,12 +5,23 @@ export { DirectiveLocation, GraphQLBoolean, GraphQLEnumType, GraphQLFieldConfigM
5
5
  export { compose, directive, enumType, execute, extension, field, getSchemaName, inputType, interfaceType, middleware, mutation, objectType, query, subscription, unionType } from './builder/index.js';
6
6
  import { Effect, Context, Layer, Ref, HashMap, Option } from 'effect';
7
7
  import * as S from 'effect/Schema';
8
+ import * as AST from 'effect/SchemaAST';
8
9
  import * as effect_Cause from 'effect/Cause';
9
10
  import * as effect_Types from 'effect/Types';
10
11
  import DataLoader from 'dataloader';
11
12
  export { CloseEvent, CompleteMessage, ConnectionContext, EffectSSE, EffectWebSocket, ErrorHandler, GraphQLRouterConfig, GraphQLRouterConfigFromEnv, GraphQLRouterConfigInput, GraphQLSSEConfig, GraphQLSSEOptions, GraphQLWSConfig, GraphQLWSOptions, GraphiQLConfig, MakeGraphQLRouterOptions, SSEConnectionContext, SSEError, SSEEvent, SSEEventType, SSESubscriptionRequest, SSESubscriptionResult, SSE_HEADERS, SubscribeMessage, WS_CLOSED, WebSocketError, WsWebSocket, defaultConfig, defaultErrorHandler, formatCompleteEvent, formatErrorEvent, formatNextEvent, formatSSEMessage, graphiqlHtml, makeGraphQLRouter, makeGraphQLSSEHandler, makeGraphQLWSHandler, makeSSESubscriptionStream, normalizeConfig, toEffectWebSocketFromWs, toRouter } from './server/index.js';
12
13
  import '@effect/platform';
13
14
 
15
+ /**
16
+ * Check if a Declaration AST node represents an Option type.
17
+ * Option declarations have a TypeConstructor annotation of 'effect/Option'.
18
+ */
19
+ declare const isOptionDeclaration: (ast: AST.AST) => boolean;
20
+ /**
21
+ * Check if a Transformation represents an Option schema (e.g., S.OptionFromNullOr).
22
+ * These have a Declaration with "Option" identifier on the "to" side.
23
+ */
24
+ declare const isOptionTransformation: (ast: AST.AST) => boolean;
14
25
  /**
15
26
  * Convert an Effect Schema to a GraphQL output type
16
27
  */
@@ -526,4 +537,4 @@ interface AnalyzerOutput {
526
537
  */
527
538
  declare const createAnalyzerExtension: (config?: AnalyzerExtensionConfig) => GraphQLExtension<ExtensionsService>;
528
539
 
529
- export { type AdditionalField, type AnalyzerExtensionConfig, type AnalyzerOutput, AuthorizationError, ExtensionsService, FieldComplexityMap, GraphQLError, GraphQLExtension, GraphQLRequestContext, type GroupedLoaderDef, Loader, type LoaderDef, type LoaderInstances, LoaderRegistry, MissingResolverContextError, NotFoundError, ResolverContext, type ResolverContextSlot, ResolverContextStore, type SingleLoaderDef, ValidationError, createAnalyzerExtension, get, getOption, getOrElse, has, make, makeRequestContextLayer, makeStoreLayer, scoped, set, setMany, storeLayer, toGraphQLArgs, toGraphQLInputType, toGraphQLObjectType, toGraphQLType };
540
+ export { type AdditionalField, type AnalyzerExtensionConfig, type AnalyzerOutput, AuthorizationError, ExtensionsService, FieldComplexityMap, GraphQLError, GraphQLExtension, GraphQLRequestContext, type GroupedLoaderDef, Loader, type LoaderDef, type LoaderInstances, LoaderRegistry, MissingResolverContextError, NotFoundError, ResolverContext, type ResolverContextSlot, ResolverContextStore, type SingleLoaderDef, ValidationError, createAnalyzerExtension, get, getOption, getOrElse, has, isOptionDeclaration, isOptionTransformation, make, makeRequestContextLayer, makeStoreLayer, scoped, set, setMany, storeLayer, toGraphQLArgs, toGraphQLInputType, toGraphQLObjectType, toGraphQLType };
package/index.js CHANGED
@@ -59,7 +59,7 @@ function handleTupleTypeAST(ast, convertFn) {
59
59
  }
60
60
  return void 0;
61
61
  }
62
- function buildFieldsFromPropertySignatures(propertySignatures, convertFn, isInput) {
62
+ function buildFieldsFromPropertySignatures(propertySignatures, convertFn) {
63
63
  const fields = {};
64
64
  for (const field2 of propertySignatures) {
65
65
  const fieldName = String(field2.name);
@@ -168,7 +168,8 @@ var toGraphQLInputType = (schema) => {
168
168
  if (ast._tag === "TypeLiteral") {
169
169
  const fields = buildFieldsFromPropertySignatures(
170
170
  ast.propertySignatures,
171
- toGraphQLInputType);
171
+ toGraphQLInputType
172
+ );
172
173
  const typeName = schema.annotations?.identifier || `Input_${Math.random().toString(36).slice(2, 11)}`;
173
174
  return new GraphQLInputObjectType({
174
175
  name: typeName,
@@ -363,7 +364,7 @@ function toGraphQLTypeWithRegistry(schema, ctx) {
363
364
  return handleTupleTypeAST2(ast, ctx);
364
365
  }
365
366
  if (ast._tag === "Declaration") {
366
- if (isOptionDeclaration2(ast)) {
367
+ if (isOptionDeclaration(ast)) {
367
368
  const innerType = getOptionInnerType2(ast);
368
369
  if (innerType) {
369
370
  return toGraphQLTypeWithRegistry(S2.make(innerType), ctx);
@@ -394,19 +395,6 @@ function findRegisteredInterface(schema, ast, ctx) {
394
395
  }
395
396
  return void 0;
396
397
  }
397
- function isOptionDeclaration2(ast) {
398
- if (ast._tag === "Declaration") {
399
- const annotations = ast.annotations;
400
- if (annotations) {
401
- const TypeConstructorSymbol = /* @__PURE__ */ Symbol.for("effect/annotation/TypeConstructor");
402
- const typeConstructor = annotations[TypeConstructorSymbol];
403
- if (typeConstructor && typeConstructor._tag === "effect/Option") {
404
- return true;
405
- }
406
- }
407
- }
408
- return false;
409
- }
410
398
  function getOptionInnerType2(ast) {
411
399
  if (ast._tag === "Declaration") {
412
400
  const typeParams = ast.typeParameters;
@@ -507,7 +495,7 @@ function handleArrayTransformation(toAst, ctx) {
507
495
  function handleTransformationAST(ast, ctx) {
508
496
  const toAst = ast.to;
509
497
  const fromAst = ast.from;
510
- if (isOptionDeclaration2(toAst)) {
498
+ if (isOptionDeclaration(toAst)) {
511
499
  const optionResult = handleOptionTransformation(ast, fromAst, toAst, ctx);
512
500
  if (optionResult) return optionResult;
513
501
  }
@@ -613,7 +601,8 @@ function schemaToFields(schema, ctx) {
613
601
  if (fieldName === "_tag") continue;
614
602
  const fieldSchema = S2.make(field2.type);
615
603
  let fieldType = toGraphQLTypeWithRegistry(fieldSchema, ctx);
616
- if (!field2.isOptional) {
604
+ const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
605
+ if (!field2.isOptional && !isOptionField) {
617
606
  fieldType = getNonNull(fieldType);
618
607
  }
619
608
  fields[fieldName] = { type: fieldType };
@@ -641,7 +630,8 @@ function schemaToInputFields(schema, enumRegistry, inputRegistry, inputs, enums,
641
630
  enums,
642
631
  cache
643
632
  );
644
- if (!field2.isOptional) {
633
+ const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
634
+ if (!field2.isOptional && !isOptionField) {
645
635
  fieldType = getNonNull(fieldType);
646
636
  }
647
637
  fields[fieldName] = { type: fieldType };
@@ -832,7 +822,7 @@ function handleOptionTransformationForInput(fromAst, toAst, inputs, inputRegistr
832
822
  function handleTransformationForInput(ast, inputs, inputRegistry, enumRegistry, enums, cache) {
833
823
  const toAst = ast.to;
834
824
  const fromAst = ast.from;
835
- if (isOptionDeclaration2(toAst)) {
825
+ if (isOptionDeclaration(toAst)) {
836
826
  const optionResult = handleOptionTransformationForInput(
837
827
  fromAst,
838
828
  toAst,
@@ -3756,6 +3746,6 @@ function checkThresholds(result, thresholds) {
3756
3746
  return Effect.void;
3757
3747
  }
3758
3748
 
3759
- export { AuthorizationError, CacheControlConfigFromEnv, ComplexityAnalysisError, ComplexityConfigFromEnv, ComplexityLimitExceededError, ExtensionsService, GraphQLError2 as GraphQLError, GraphQLRequestContext, GraphQLRouterConfigFromEnv, GraphQLSchemaBuilder, Loader, MissingResolverContextError, NotFoundError, ResolverContext, ResolverContextStore, SSEError, SSE_HEADERS, ValidationError, WS_CLOSED, WebSocketError, combineCalculators, compose, computeCachePolicy, computeCachePolicyFromQuery, createAnalyzerExtension, defaultComplexityCalculator, defaultConfig, defaultErrorHandler, depthOnlyCalculator, directive, enumType, execute, extension, field, formatCompleteEvent, formatErrorEvent, formatNextEvent, formatSSEMessage, get, getOption, getOrElse, getSchemaName, graphiqlHtml, has, inputType, interfaceType, make3 as make, makeExtensionsService, makeGraphQLRouter, makeGraphQLSSEHandler, makeGraphQLWSHandler, makeRequestContextLayer, makeSSESubscriptionStream, makeStoreLayer, middleware, mutation, normalizeConfig, objectType, query, runExecuteEndHooks, runExecuteStartHooks, runParseHooks, runValidateHooks, scoped, set, setMany, storeLayer, subscription, toCacheControlHeader, toEffectWebSocketFromWs, toGraphQLArgs, toGraphQLInputType, toGraphQLObjectType, toGraphQLType, toRouter, unionType, validateComplexity };
3749
+ export { AuthorizationError, CacheControlConfigFromEnv, ComplexityAnalysisError, ComplexityConfigFromEnv, ComplexityLimitExceededError, ExtensionsService, GraphQLError2 as GraphQLError, GraphQLRequestContext, GraphQLRouterConfigFromEnv, GraphQLSchemaBuilder, Loader, MissingResolverContextError, NotFoundError, ResolverContext, ResolverContextStore, SSEError, SSE_HEADERS, ValidationError, WS_CLOSED, WebSocketError, combineCalculators, compose, computeCachePolicy, computeCachePolicyFromQuery, createAnalyzerExtension, defaultComplexityCalculator, defaultConfig, defaultErrorHandler, depthOnlyCalculator, directive, enumType, execute, extension, field, formatCompleteEvent, formatErrorEvent, formatNextEvent, formatSSEMessage, get, getOption, getOrElse, getSchemaName, graphiqlHtml, has, inputType, interfaceType, isOptionDeclaration, isOptionTransformation, make3 as make, makeExtensionsService, makeGraphQLRouter, makeGraphQLSSEHandler, makeGraphQLWSHandler, makeRequestContextLayer, makeSSESubscriptionStream, makeStoreLayer, middleware, mutation, normalizeConfig, objectType, query, runExecuteEndHooks, runExecuteStartHooks, runParseHooks, runValidateHooks, scoped, set, setMany, storeLayer, subscription, toCacheControlHeader, toEffectWebSocketFromWs, toGraphQLArgs, toGraphQLInputType, toGraphQLObjectType, toGraphQLType, toRouter, unionType, validateComplexity };
3760
3750
  //# sourceMappingURL=index.js.map
3761
3751
  //# sourceMappingURL=index.js.map