@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.js CHANGED
@@ -78,6 +78,7 @@ var toGraphQLType = (schema) => {
78
78
  const fields = {};
79
79
  for (const field2 of ast.propertySignatures) {
80
80
  const fieldName = String(field2.name);
81
+ if (fieldName === "_tag") continue;
81
82
  const fieldSchema = S.make(field2.type);
82
83
  let fieldType = toGraphQLType(fieldSchema);
83
84
  if (!field2.isOptional) {
@@ -153,6 +154,7 @@ var toGraphQLInputType = (schema) => {
153
154
  const fields = {};
154
155
  for (const field2 of ast.propertySignatures) {
155
156
  const fieldName = String(field2.name);
157
+ if (fieldName === "_tag") continue;
156
158
  const fieldSchema = S.make(field2.type);
157
159
  let fieldType = toGraphQLInputType(fieldSchema);
158
160
  if (!field2.isOptional) {
@@ -215,6 +217,7 @@ var toGraphQLObjectType = (name, schema, additionalFields) => {
215
217
  const fields = {};
216
218
  for (const field2 of ast.propertySignatures) {
217
219
  const fieldName = String(field2.name);
220
+ if (fieldName === "_tag") continue;
218
221
  const fieldSchema = S.make(field2.type);
219
222
  let fieldType = toGraphQLType(fieldSchema);
220
223
  if (!field2.isOptional) {
@@ -246,6 +249,7 @@ var toGraphQLArgs = (schema) => {
246
249
  const args = {};
247
250
  for (const field2 of ast.propertySignatures) {
248
251
  const fieldName = String(field2.name);
252
+ if (fieldName === "_tag") continue;
249
253
  const fieldSchema = S.make(field2.type);
250
254
  let fieldType = toGraphQLInputType(fieldSchema);
251
255
  if (!field2.isOptional) {
@@ -493,14 +497,21 @@ function schemaToFields(schema, ctx) {
493
497
  }
494
498
  if (ast._tag === "Declaration") {
495
499
  const typeParams = ast.typeParameters;
496
- if (typeParams && typeParams.length > 0 && typeParams[0]._tag === "TypeLiteral") {
497
- ast = typeParams[0];
500
+ if (typeParams && typeParams.length > 0) {
501
+ let innerAst = typeParams[0];
502
+ while (innerAst._tag === "Transformation") {
503
+ innerAst = innerAst.to;
504
+ }
505
+ if (innerAst._tag === "TypeLiteral") {
506
+ ast = innerAst;
507
+ }
498
508
  }
499
509
  }
500
510
  if (ast._tag === "TypeLiteral") {
501
511
  const fields = {};
502
512
  for (const field2 of ast.propertySignatures) {
503
513
  const fieldName = String(field2.name);
514
+ if (fieldName === "_tag") continue;
504
515
  const fieldSchema = S.make(field2.type);
505
516
  let fieldType = toGraphQLTypeWithRegistry(fieldSchema, ctx);
506
517
  if (!field2.isOptional) {
@@ -513,11 +524,15 @@ function schemaToFields(schema, ctx) {
513
524
  return {};
514
525
  }
515
526
  function schemaToInputFields(schema, enumRegistry, inputRegistry, inputs, enums, cache) {
516
- const ast = schema.ast;
527
+ let ast = schema.ast;
528
+ while (ast._tag === "Transformation") {
529
+ ast = ast.to;
530
+ }
517
531
  if (ast._tag === "TypeLiteral") {
518
532
  const fields = {};
519
533
  for (const field2 of ast.propertySignatures) {
520
534
  const fieldName = String(field2.name);
535
+ if (fieldName === "_tag") continue;
521
536
  const fieldSchema = S.make(field2.type);
522
537
  let fieldType = toGraphQLInputTypeWithRegistry(
523
538
  fieldSchema,
@@ -557,17 +572,6 @@ function buildInputTypeLookupCache(inputs, enums) {
557
572
  }
558
573
  function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inputs, enums, cache) {
559
574
  const ast = schema.ast;
560
- if (ast._tag === "Transformation") {
561
- const toAst = ast.to;
562
- return toGraphQLInputTypeWithRegistry(
563
- S.make(toAst),
564
- enumRegistry,
565
- inputRegistry,
566
- inputs,
567
- enums,
568
- cache
569
- );
570
- }
571
575
  if (cache?.schemaToInputName || cache?.astToInputName) {
572
576
  const inputName = cache.schemaToInputName?.get(schema) ?? cache.astToInputName?.get(ast);
573
577
  if (inputName) {
@@ -582,6 +586,17 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
582
586
  }
583
587
  }
584
588
  }
589
+ if (ast._tag === "Transformation") {
590
+ const toAst = ast.to;
591
+ return toGraphQLInputTypeWithRegistry(
592
+ S.make(toAst),
593
+ enumRegistry,
594
+ inputRegistry,
595
+ inputs,
596
+ enums,
597
+ cache
598
+ );
599
+ }
585
600
  if (ast._tag === "Union") {
586
601
  const unionAst = ast;
587
602
  const nonUndefinedTypes = unionAst.types.filter((t) => t._tag !== "UndefinedKeyword");
@@ -653,6 +668,7 @@ function toGraphQLArgsWithRegistry(schema, enumRegistry, inputRegistry, inputs,
653
668
  const args = {};
654
669
  for (const field2 of ast.propertySignatures) {
655
670
  const fieldName = String(field2.name);
671
+ if (fieldName === "_tag") continue;
656
672
  const fieldSchema = S.make(field2.type);
657
673
  let fieldType = toGraphQLInputTypeWithRegistry(
658
674
  fieldSchema,