@effect-gql/core 1.4.10 → 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
@@ -364,7 +364,7 @@ function toGraphQLTypeWithRegistry(schema, ctx) {
364
364
  return handleTupleTypeAST2(ast, ctx);
365
365
  }
366
366
  if (ast._tag === "Declaration") {
367
- if (isOptionDeclaration2(ast)) {
367
+ if (isOptionDeclaration(ast)) {
368
368
  const innerType = getOptionInnerType2(ast);
369
369
  if (innerType) {
370
370
  return toGraphQLTypeWithRegistry(S2.make(innerType), ctx);
@@ -395,19 +395,6 @@ function findRegisteredInterface(schema, ast, ctx) {
395
395
  }
396
396
  return void 0;
397
397
  }
398
- function isOptionDeclaration2(ast) {
399
- if (ast._tag === "Declaration") {
400
- const annotations = ast.annotations;
401
- if (annotations) {
402
- const TypeConstructorSymbol = /* @__PURE__ */ Symbol.for("effect/annotation/TypeConstructor");
403
- const typeConstructor = annotations[TypeConstructorSymbol];
404
- if (typeConstructor && typeConstructor._tag === "effect/Option") {
405
- return true;
406
- }
407
- }
408
- }
409
- return false;
410
- }
411
398
  function getOptionInnerType2(ast) {
412
399
  if (ast._tag === "Declaration") {
413
400
  const typeParams = ast.typeParameters;
@@ -508,7 +495,7 @@ function handleArrayTransformation(toAst, ctx) {
508
495
  function handleTransformationAST(ast, ctx) {
509
496
  const toAst = ast.to;
510
497
  const fromAst = ast.from;
511
- if (isOptionDeclaration2(toAst)) {
498
+ if (isOptionDeclaration(toAst)) {
512
499
  const optionResult = handleOptionTransformation(ast, fromAst, toAst, ctx);
513
500
  if (optionResult) return optionResult;
514
501
  }
@@ -614,7 +601,8 @@ function schemaToFields(schema, ctx) {
614
601
  if (fieldName === "_tag") continue;
615
602
  const fieldSchema = S2.make(field2.type);
616
603
  let fieldType = toGraphQLTypeWithRegistry(fieldSchema, ctx);
617
- if (!field2.isOptional) {
604
+ const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
605
+ if (!field2.isOptional && !isOptionField) {
618
606
  fieldType = getNonNull(fieldType);
619
607
  }
620
608
  fields[fieldName] = { type: fieldType };
@@ -642,7 +630,8 @@ function schemaToInputFields(schema, enumRegistry, inputRegistry, inputs, enums,
642
630
  enums,
643
631
  cache
644
632
  );
645
- if (!field2.isOptional) {
633
+ const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
634
+ if (!field2.isOptional && !isOptionField) {
646
635
  fieldType = getNonNull(fieldType);
647
636
  }
648
637
  fields[fieldName] = { type: fieldType };
@@ -833,7 +822,7 @@ function handleOptionTransformationForInput(fromAst, toAst, inputs, inputRegistr
833
822
  function handleTransformationForInput(ast, inputs, inputRegistry, enumRegistry, enums, cache) {
834
823
  const toAst = ast.to;
835
824
  const fromAst = ast.from;
836
- if (isOptionDeclaration2(toAst)) {
825
+ if (isOptionDeclaration(toAst)) {
837
826
  const optionResult = handleOptionTransformationForInput(
838
827
  fromAst,
839
828
  toAst,
@@ -3757,6 +3746,6 @@ function checkThresholds(result, thresholds) {
3757
3746
  return Effect.void;
3758
3747
  }
3759
3748
 
3760
- 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 };
3761
3750
  //# sourceMappingURL=index.js.map
3762
3751
  //# sourceMappingURL=index.js.map