@effect-gql/core 1.4.0 → 1.4.1

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
@@ -103,6 +103,7 @@ var toGraphQLType = (schema) => {
103
103
  const fields = {};
104
104
  for (const field2 of ast.propertySignatures) {
105
105
  const fieldName = String(field2.name);
106
+ if (fieldName === "_tag") continue;
106
107
  const fieldSchema = S__namespace.make(field2.type);
107
108
  let fieldType = toGraphQLType(fieldSchema);
108
109
  if (!field2.isOptional) {
@@ -178,6 +179,7 @@ var toGraphQLInputType = (schema) => {
178
179
  const fields = {};
179
180
  for (const field2 of ast.propertySignatures) {
180
181
  const fieldName = String(field2.name);
182
+ if (fieldName === "_tag") continue;
181
183
  const fieldSchema = S__namespace.make(field2.type);
182
184
  let fieldType = toGraphQLInputType(fieldSchema);
183
185
  if (!field2.isOptional) {
@@ -240,6 +242,7 @@ var toGraphQLObjectType = (name, schema, additionalFields) => {
240
242
  const fields = {};
241
243
  for (const field2 of ast.propertySignatures) {
242
244
  const fieldName = String(field2.name);
245
+ if (fieldName === "_tag") continue;
243
246
  const fieldSchema = S__namespace.make(field2.type);
244
247
  let fieldType = toGraphQLType(fieldSchema);
245
248
  if (!field2.isOptional) {
@@ -271,6 +274,7 @@ var toGraphQLArgs = (schema) => {
271
274
  const args = {};
272
275
  for (const field2 of ast.propertySignatures) {
273
276
  const fieldName = String(field2.name);
277
+ if (fieldName === "_tag") continue;
274
278
  const fieldSchema = S__namespace.make(field2.type);
275
279
  let fieldType = toGraphQLInputType(fieldSchema);
276
280
  if (!field2.isOptional) {
@@ -518,14 +522,21 @@ function schemaToFields(schema, ctx) {
518
522
  }
519
523
  if (ast._tag === "Declaration") {
520
524
  const typeParams = ast.typeParameters;
521
- if (typeParams && typeParams.length > 0 && typeParams[0]._tag === "TypeLiteral") {
522
- ast = typeParams[0];
525
+ if (typeParams && typeParams.length > 0) {
526
+ let innerAst = typeParams[0];
527
+ while (innerAst._tag === "Transformation") {
528
+ innerAst = innerAst.to;
529
+ }
530
+ if (innerAst._tag === "TypeLiteral") {
531
+ ast = innerAst;
532
+ }
523
533
  }
524
534
  }
525
535
  if (ast._tag === "TypeLiteral") {
526
536
  const fields = {};
527
537
  for (const field2 of ast.propertySignatures) {
528
538
  const fieldName = String(field2.name);
539
+ if (fieldName === "_tag") continue;
529
540
  const fieldSchema = S__namespace.make(field2.type);
530
541
  let fieldType = toGraphQLTypeWithRegistry(fieldSchema, ctx);
531
542
  if (!field2.isOptional) {
@@ -538,11 +549,15 @@ function schemaToFields(schema, ctx) {
538
549
  return {};
539
550
  }
540
551
  function schemaToInputFields(schema, enumRegistry, inputRegistry, inputs, enums, cache) {
541
- const ast = schema.ast;
552
+ let ast = schema.ast;
553
+ while (ast._tag === "Transformation") {
554
+ ast = ast.to;
555
+ }
542
556
  if (ast._tag === "TypeLiteral") {
543
557
  const fields = {};
544
558
  for (const field2 of ast.propertySignatures) {
545
559
  const fieldName = String(field2.name);
560
+ if (fieldName === "_tag") continue;
546
561
  const fieldSchema = S__namespace.make(field2.type);
547
562
  let fieldType = toGraphQLInputTypeWithRegistry(
548
563
  fieldSchema,
@@ -582,17 +597,6 @@ function buildInputTypeLookupCache(inputs, enums) {
582
597
  }
583
598
  function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inputs, enums, cache) {
584
599
  const ast = schema.ast;
585
- if (ast._tag === "Transformation") {
586
- const toAst = ast.to;
587
- return toGraphQLInputTypeWithRegistry(
588
- S__namespace.make(toAst),
589
- enumRegistry,
590
- inputRegistry,
591
- inputs,
592
- enums,
593
- cache
594
- );
595
- }
596
600
  if (cache?.schemaToInputName || cache?.astToInputName) {
597
601
  const inputName = cache.schemaToInputName?.get(schema) ?? cache.astToInputName?.get(ast);
598
602
  if (inputName) {
@@ -607,6 +611,17 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
607
611
  }
608
612
  }
609
613
  }
614
+ if (ast._tag === "Transformation") {
615
+ const toAst = ast.to;
616
+ return toGraphQLInputTypeWithRegistry(
617
+ S__namespace.make(toAst),
618
+ enumRegistry,
619
+ inputRegistry,
620
+ inputs,
621
+ enums,
622
+ cache
623
+ );
624
+ }
610
625
  if (ast._tag === "Union") {
611
626
  const unionAst = ast;
612
627
  const nonUndefinedTypes = unionAst.types.filter((t) => t._tag !== "UndefinedKeyword");
@@ -678,6 +693,7 @@ function toGraphQLArgsWithRegistry(schema, enumRegistry, inputRegistry, inputs,
678
693
  const args = {};
679
694
  for (const field2 of ast.propertySignatures) {
680
695
  const fieldName = String(field2.name);
696
+ if (fieldName === "_tag") continue;
681
697
  const fieldSchema = S__namespace.make(field2.type);
682
698
  let fieldType = toGraphQLInputTypeWithRegistry(
683
699
  fieldSchema,