@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.cjs CHANGED
@@ -84,7 +84,7 @@ function handleTupleTypeAST(ast, convertFn) {
84
84
  }
85
85
  return void 0;
86
86
  }
87
- function buildFieldsFromPropertySignatures(propertySignatures, convertFn, isInput) {
87
+ function buildFieldsFromPropertySignatures(propertySignatures, convertFn) {
88
88
  const fields = {};
89
89
  for (const field2 of propertySignatures) {
90
90
  const fieldName = String(field2.name);
@@ -193,7 +193,8 @@ var toGraphQLInputType = (schema) => {
193
193
  if (ast._tag === "TypeLiteral") {
194
194
  const fields = buildFieldsFromPropertySignatures(
195
195
  ast.propertySignatures,
196
- toGraphQLInputType);
196
+ toGraphQLInputType
197
+ );
197
198
  const typeName = schema.annotations?.identifier || `Input_${Math.random().toString(36).slice(2, 11)}`;
198
199
  return new graphql.GraphQLInputObjectType({
199
200
  name: typeName,
@@ -388,7 +389,7 @@ function toGraphQLTypeWithRegistry(schema, ctx) {
388
389
  return handleTupleTypeAST2(ast, ctx);
389
390
  }
390
391
  if (ast._tag === "Declaration") {
391
- if (isOptionDeclaration2(ast)) {
392
+ if (isOptionDeclaration(ast)) {
392
393
  const innerType = getOptionInnerType2(ast);
393
394
  if (innerType) {
394
395
  return toGraphQLTypeWithRegistry(S2__namespace.make(innerType), ctx);
@@ -419,19 +420,6 @@ function findRegisteredInterface(schema, ast, ctx) {
419
420
  }
420
421
  return void 0;
421
422
  }
422
- function isOptionDeclaration2(ast) {
423
- if (ast._tag === "Declaration") {
424
- const annotations = ast.annotations;
425
- if (annotations) {
426
- const TypeConstructorSymbol = /* @__PURE__ */ Symbol.for("effect/annotation/TypeConstructor");
427
- const typeConstructor = annotations[TypeConstructorSymbol];
428
- if (typeConstructor && typeConstructor._tag === "effect/Option") {
429
- return true;
430
- }
431
- }
432
- }
433
- return false;
434
- }
435
423
  function getOptionInnerType2(ast) {
436
424
  if (ast._tag === "Declaration") {
437
425
  const typeParams = ast.typeParameters;
@@ -532,7 +520,7 @@ function handleArrayTransformation(toAst, ctx) {
532
520
  function handleTransformationAST(ast, ctx) {
533
521
  const toAst = ast.to;
534
522
  const fromAst = ast.from;
535
- if (isOptionDeclaration2(toAst)) {
523
+ if (isOptionDeclaration(toAst)) {
536
524
  const optionResult = handleOptionTransformation(ast, fromAst, toAst, ctx);
537
525
  if (optionResult) return optionResult;
538
526
  }
@@ -638,7 +626,8 @@ function schemaToFields(schema, ctx) {
638
626
  if (fieldName === "_tag") continue;
639
627
  const fieldSchema = S2__namespace.make(field2.type);
640
628
  let fieldType = toGraphQLTypeWithRegistry(fieldSchema, ctx);
641
- if (!field2.isOptional) {
629
+ const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
630
+ if (!field2.isOptional && !isOptionField) {
642
631
  fieldType = getNonNull(fieldType);
643
632
  }
644
633
  fields[fieldName] = { type: fieldType };
@@ -666,7 +655,8 @@ function schemaToInputFields(schema, enumRegistry, inputRegistry, inputs, enums,
666
655
  enums,
667
656
  cache
668
657
  );
669
- if (!field2.isOptional) {
658
+ const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
659
+ if (!field2.isOptional && !isOptionField) {
670
660
  fieldType = getNonNull(fieldType);
671
661
  }
672
662
  fields[fieldName] = { type: fieldType };
@@ -857,7 +847,7 @@ function handleOptionTransformationForInput(fromAst, toAst, inputs, inputRegistr
857
847
  function handleTransformationForInput(ast, inputs, inputRegistry, enumRegistry, enums, cache) {
858
848
  const toAst = ast.to;
859
849
  const fromAst = ast.from;
860
- if (isOptionDeclaration2(toAst)) {
850
+ if (isOptionDeclaration(toAst)) {
861
851
  const optionResult = handleOptionTransformationForInput(
862
852
  fromAst,
863
853
  toAst,
@@ -3903,6 +3893,8 @@ exports.graphiqlHtml = graphiqlHtml;
3903
3893
  exports.has = has;
3904
3894
  exports.inputType = inputType;
3905
3895
  exports.interfaceType = interfaceType;
3896
+ exports.isOptionDeclaration = isOptionDeclaration;
3897
+ exports.isOptionTransformation = isOptionTransformation;
3906
3898
  exports.make = make3;
3907
3899
  exports.makeExtensionsService = makeExtensionsService;
3908
3900
  exports.makeGraphQLRouter = makeGraphQLRouter;