@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/builder/index.js CHANGED
@@ -57,7 +57,7 @@ function handleTupleTypeAST(ast, convertFn) {
57
57
  }
58
58
  return void 0;
59
59
  }
60
- function buildFieldsFromPropertySignatures(propertySignatures, convertFn, isInput) {
60
+ function buildFieldsFromPropertySignatures(propertySignatures, convertFn) {
61
61
  const fields = {};
62
62
  for (const field2 of propertySignatures) {
63
63
  const fieldName = String(field2.name);
@@ -166,7 +166,8 @@ var toGraphQLInputType = (schema) => {
166
166
  if (ast._tag === "TypeLiteral") {
167
167
  const fields = buildFieldsFromPropertySignatures(
168
168
  ast.propertySignatures,
169
- toGraphQLInputType);
169
+ toGraphQLInputType
170
+ );
170
171
  const typeName = schema.annotations?.identifier || `Input_${Math.random().toString(36).slice(2, 11)}`;
171
172
  return new GraphQLInputObjectType({
172
173
  name: typeName,
@@ -326,7 +327,7 @@ function toGraphQLTypeWithRegistry(schema, ctx) {
326
327
  return handleTupleTypeAST2(ast, ctx);
327
328
  }
328
329
  if (ast._tag === "Declaration") {
329
- if (isOptionDeclaration2(ast)) {
330
+ if (isOptionDeclaration(ast)) {
330
331
  const innerType = getOptionInnerType2(ast);
331
332
  if (innerType) {
332
333
  return toGraphQLTypeWithRegistry(S2.make(innerType), ctx);
@@ -357,19 +358,6 @@ function findRegisteredInterface(schema, ast, ctx) {
357
358
  }
358
359
  return void 0;
359
360
  }
360
- function isOptionDeclaration2(ast) {
361
- if (ast._tag === "Declaration") {
362
- const annotations = ast.annotations;
363
- if (annotations) {
364
- const TypeConstructorSymbol = /* @__PURE__ */ Symbol.for("effect/annotation/TypeConstructor");
365
- const typeConstructor = annotations[TypeConstructorSymbol];
366
- if (typeConstructor && typeConstructor._tag === "effect/Option") {
367
- return true;
368
- }
369
- }
370
- }
371
- return false;
372
- }
373
361
  function getOptionInnerType2(ast) {
374
362
  if (ast._tag === "Declaration") {
375
363
  const typeParams = ast.typeParameters;
@@ -470,7 +458,7 @@ function handleArrayTransformation(toAst, ctx) {
470
458
  function handleTransformationAST(ast, ctx) {
471
459
  const toAst = ast.to;
472
460
  const fromAst = ast.from;
473
- if (isOptionDeclaration2(toAst)) {
461
+ if (isOptionDeclaration(toAst)) {
474
462
  const optionResult = handleOptionTransformation(ast, fromAst, toAst, ctx);
475
463
  if (optionResult) return optionResult;
476
464
  }
@@ -576,7 +564,8 @@ function schemaToFields(schema, ctx) {
576
564
  if (fieldName === "_tag") continue;
577
565
  const fieldSchema = S2.make(field2.type);
578
566
  let fieldType = toGraphQLTypeWithRegistry(fieldSchema, ctx);
579
- if (!field2.isOptional) {
567
+ const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
568
+ if (!field2.isOptional && !isOptionField) {
580
569
  fieldType = getNonNull(fieldType);
581
570
  }
582
571
  fields[fieldName] = { type: fieldType };
@@ -604,7 +593,8 @@ function schemaToInputFields(schema, enumRegistry, inputRegistry, inputs, enums,
604
593
  enums,
605
594
  cache
606
595
  );
607
- if (!field2.isOptional) {
596
+ const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
597
+ if (!field2.isOptional && !isOptionField) {
608
598
  fieldType = getNonNull(fieldType);
609
599
  }
610
600
  fields[fieldName] = { type: fieldType };
@@ -795,7 +785,7 @@ function handleOptionTransformationForInput(fromAst, toAst, inputs, inputRegistr
795
785
  function handleTransformationForInput(ast, inputs, inputRegistry, enumRegistry, enums, cache) {
796
786
  const toAst = ast.to;
797
787
  const fromAst = ast.from;
798
- if (isOptionDeclaration2(toAst)) {
788
+ if (isOptionDeclaration(toAst)) {
799
789
  const optionResult = handleOptionTransformationForInput(
800
790
  fromAst,
801
791
  toAst,