@effect-gql/core 1.4.3 → 1.4.4

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  var graphql = require('graphql');
4
4
  var effect = require('effect');
5
- var S = require('effect/Schema');
5
+ var S2 = require('effect/Schema');
6
6
  var AST = require('effect/SchemaAST');
7
7
  var DataLoader = require('dataloader');
8
8
  var platform = require('@effect/platform');
@@ -27,7 +27,7 @@ function _interopNamespace(e) {
27
27
  return Object.freeze(n);
28
28
  }
29
29
 
30
- var S__namespace = /*#__PURE__*/_interopNamespace(S);
30
+ var S2__namespace = /*#__PURE__*/_interopNamespace(S2);
31
31
  var AST__namespace = /*#__PURE__*/_interopNamespace(AST);
32
32
  var DataLoader__default = /*#__PURE__*/_interopDefault(DataLoader);
33
33
 
@@ -83,7 +83,7 @@ var toGraphQLType = (schema) => {
83
83
  if (isIntegerType(ast)) {
84
84
  return graphql.GraphQLInt;
85
85
  }
86
- return toGraphQLType(S__namespace.make(ast.from));
86
+ return toGraphQLType(S2__namespace.make(ast.from));
87
87
  }
88
88
  if (ast._tag === "Literal") {
89
89
  if (typeof ast.literal === "string") return graphql.GraphQLString;
@@ -95,7 +95,7 @@ var toGraphQLType = (schema) => {
95
95
  if (ast._tag === "TupleType") {
96
96
  const elements = ast.elements;
97
97
  if (elements.length > 0) {
98
- const elementSchema = S__namespace.make(elements[0].type);
98
+ const elementSchema = S2__namespace.make(elements[0].type);
99
99
  return new graphql.GraphQLList(toGraphQLType(elementSchema));
100
100
  }
101
101
  }
@@ -104,7 +104,7 @@ var toGraphQLType = (schema) => {
104
104
  for (const field2 of ast.propertySignatures) {
105
105
  const fieldName = String(field2.name);
106
106
  if (fieldName === "_tag") continue;
107
- const fieldSchema = S__namespace.make(field2.type);
107
+ const fieldSchema = S2__namespace.make(field2.type);
108
108
  let fieldType = toGraphQLType(fieldSchema);
109
109
  if (!field2.isOptional) {
110
110
  fieldType = new graphql.GraphQLNonNull(fieldType);
@@ -121,32 +121,32 @@ var toGraphQLType = (schema) => {
121
121
  if (isOptionTransformation(ast)) {
122
122
  const innerType = getOptionInnerType(ast.to);
123
123
  if (innerType) {
124
- return toGraphQLType(S__namespace.make(innerType));
124
+ return toGraphQLType(S2__namespace.make(innerType));
125
125
  }
126
126
  }
127
- return toGraphQLType(S__namespace.make(ast.to));
127
+ return toGraphQLType(S2__namespace.make(ast.to));
128
128
  }
129
129
  if (ast._tag === "Declaration") {
130
130
  if (isOptionDeclaration(ast)) {
131
131
  const innerType = getOptionInnerType(ast);
132
132
  if (innerType) {
133
- return toGraphQLType(S__namespace.make(innerType));
133
+ return toGraphQLType(S2__namespace.make(innerType));
134
134
  }
135
135
  }
136
136
  const typeParams = ast.typeParameters;
137
137
  if (typeParams && typeParams.length > 0) {
138
- return toGraphQLType(S__namespace.make(typeParams[0]));
138
+ return toGraphQLType(S2__namespace.make(typeParams[0]));
139
139
  }
140
140
  }
141
141
  if (ast._tag === "Union") {
142
142
  const types = ast.types;
143
143
  if (types.length > 0) {
144
- return toGraphQLType(S__namespace.make(types[0]));
144
+ return toGraphQLType(S2__namespace.make(types[0]));
145
145
  }
146
146
  }
147
147
  if (ast._tag === "Suspend") {
148
148
  const innerAst = ast.f();
149
- return toGraphQLType(S__namespace.make(innerAst));
149
+ return toGraphQLType(S2__namespace.make(innerAst));
150
150
  }
151
151
  return graphql.GraphQLString;
152
152
  };
@@ -159,7 +159,7 @@ var toGraphQLInputType = (schema) => {
159
159
  if (isIntegerType(ast)) {
160
160
  return graphql.GraphQLInt;
161
161
  }
162
- return toGraphQLInputType(S__namespace.make(ast.from));
162
+ return toGraphQLInputType(S2__namespace.make(ast.from));
163
163
  }
164
164
  if (ast._tag === "Literal") {
165
165
  if (typeof ast.literal === "string") return graphql.GraphQLString;
@@ -171,7 +171,7 @@ var toGraphQLInputType = (schema) => {
171
171
  if (ast._tag === "TupleType") {
172
172
  const elements = ast.elements;
173
173
  if (elements.length > 0) {
174
- const elementSchema = S__namespace.make(elements[0].type);
174
+ const elementSchema = S2__namespace.make(elements[0].type);
175
175
  return new graphql.GraphQLList(toGraphQLInputType(elementSchema));
176
176
  }
177
177
  }
@@ -180,7 +180,7 @@ var toGraphQLInputType = (schema) => {
180
180
  for (const field2 of ast.propertySignatures) {
181
181
  const fieldName = String(field2.name);
182
182
  if (fieldName === "_tag") continue;
183
- const fieldSchema = S__namespace.make(field2.type);
183
+ const fieldSchema = S2__namespace.make(field2.type);
184
184
  let fieldType = toGraphQLInputType(fieldSchema);
185
185
  if (!field2.isOptional) {
186
186
  fieldType = new graphql.GraphQLNonNull(fieldType);
@@ -194,33 +194,33 @@ var toGraphQLInputType = (schema) => {
194
194
  });
195
195
  }
196
196
  if (ast._tag === "Transformation") {
197
- return toGraphQLInputType(S__namespace.make(ast.from));
197
+ return toGraphQLInputType(S2__namespace.make(ast.from));
198
198
  }
199
199
  if (ast._tag === "Declaration") {
200
200
  if (isOptionDeclaration(ast)) {
201
201
  const innerType = getOptionInnerType(ast);
202
202
  if (innerType) {
203
- return toGraphQLInputType(S__namespace.make(innerType));
203
+ return toGraphQLInputType(S2__namespace.make(innerType));
204
204
  }
205
205
  }
206
206
  const typeParams = ast.typeParameters;
207
207
  if (typeParams && typeParams.length > 0) {
208
- return toGraphQLInputType(S__namespace.make(typeParams[0]));
208
+ return toGraphQLInputType(S2__namespace.make(typeParams[0]));
209
209
  }
210
210
  }
211
211
  if (ast._tag === "Union") {
212
212
  const types = ast.types;
213
213
  const nonNullTypes = types.filter((t) => t._tag !== "Literal" || t.literal !== null).filter((t) => t._tag !== "UndefinedKeyword");
214
214
  if (nonNullTypes.length > 0) {
215
- return toGraphQLInputType(S__namespace.make(nonNullTypes[0]));
215
+ return toGraphQLInputType(S2__namespace.make(nonNullTypes[0]));
216
216
  }
217
217
  if (types.length > 0) {
218
- return toGraphQLInputType(S__namespace.make(types[0]));
218
+ return toGraphQLInputType(S2__namespace.make(types[0]));
219
219
  }
220
220
  }
221
221
  if (ast._tag === "Suspend") {
222
222
  const innerAst = ast.f();
223
- return toGraphQLInputType(S__namespace.make(innerAst));
223
+ return toGraphQLInputType(S2__namespace.make(innerAst));
224
224
  }
225
225
  return graphql.GraphQLString;
226
226
  };
@@ -243,7 +243,7 @@ var toGraphQLObjectType = (name, schema, additionalFields) => {
243
243
  for (const field2 of ast.propertySignatures) {
244
244
  const fieldName = String(field2.name);
245
245
  if (fieldName === "_tag") continue;
246
- const fieldSchema = S__namespace.make(field2.type);
246
+ const fieldSchema = S2__namespace.make(field2.type);
247
247
  let fieldType = toGraphQLType(fieldSchema);
248
248
  if (!field2.isOptional) {
249
249
  fieldType = new graphql.GraphQLNonNull(fieldType);
@@ -275,7 +275,7 @@ var toGraphQLArgs = (schema) => {
275
275
  for (const field2 of ast.propertySignatures) {
276
276
  const fieldName = String(field2.name);
277
277
  if (fieldName === "_tag") continue;
278
- const fieldSchema = S__namespace.make(field2.type);
278
+ const fieldSchema = S2__namespace.make(field2.type);
279
279
  let fieldType = toGraphQLInputType(fieldSchema);
280
280
  if (!field2.isOptional) {
281
281
  fieldType = new graphql.GraphQLNonNull(fieldType);
@@ -403,17 +403,17 @@ function toGraphQLTypeWithRegistry(schema, ctx) {
403
403
  if (isOptionDeclaration2(ast)) {
404
404
  const innerType = getOptionInnerType2(ast);
405
405
  if (innerType) {
406
- return toGraphQLTypeWithRegistry(S__namespace.make(innerType), ctx);
406
+ return toGraphQLTypeWithRegistry(S2__namespace.make(innerType), ctx);
407
407
  }
408
408
  }
409
409
  const typeParams = ast.typeParameters;
410
410
  if (typeParams && typeParams.length > 0) {
411
- return toGraphQLTypeWithRegistry(S__namespace.make(typeParams[0]), ctx);
411
+ return toGraphQLTypeWithRegistry(S2__namespace.make(typeParams[0]), ctx);
412
412
  }
413
413
  }
414
414
  if (ast._tag === "Suspend") {
415
415
  const innerAst = ast.f();
416
- return toGraphQLTypeWithRegistry(S__namespace.make(innerAst), ctx);
416
+ return toGraphQLTypeWithRegistry(S2__namespace.make(innerAst), ctx);
417
417
  }
418
418
  return toGraphQLType(schema);
419
419
  }
@@ -478,21 +478,21 @@ function handleTransformationAST(ast, ctx) {
478
478
  }
479
479
  const innerType = getOptionInnerType2(toAst);
480
480
  if (innerType) {
481
- return toGraphQLTypeWithRegistry(S__namespace.make(innerType), ctx);
481
+ return toGraphQLTypeWithRegistry(S2__namespace.make(innerType), ctx);
482
482
  }
483
483
  }
484
484
  if (toAst._tag === "TupleType") {
485
485
  if (toAst.rest && toAst.rest.length > 0) {
486
- const elementSchema = S__namespace.make(toAst.rest[0].type);
486
+ const elementSchema = S2__namespace.make(toAst.rest[0].type);
487
487
  const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
488
488
  return new graphql.GraphQLList(elementType);
489
489
  } else if (toAst.elements.length > 0) {
490
- const elementSchema = S__namespace.make(toAst.elements[0].type);
490
+ const elementSchema = S2__namespace.make(toAst.elements[0].type);
491
491
  const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
492
492
  return new graphql.GraphQLList(elementType);
493
493
  }
494
494
  }
495
- return toGraphQLTypeWithRegistry(S__namespace.make(ast.to), ctx);
495
+ return toGraphQLTypeWithRegistry(S2__namespace.make(ast.to), ctx);
496
496
  }
497
497
  function handleUnionAST(ast, ctx) {
498
498
  const allLiterals = ast.types.every((t) => t._tag === "Literal");
@@ -517,11 +517,22 @@ function handleUnionAST(ast, ctx) {
517
517
  if (result) return result;
518
518
  }
519
519
  }
520
+ if (memberAst._tag === "TypeLiteral") {
521
+ const valueField = memberAst.propertySignatures?.find(
522
+ (p) => String(p.name) === "value"
523
+ );
524
+ if (valueField) {
525
+ const innerResult = toGraphQLTypeWithRegistry(S2__namespace.make(valueField.type), ctx);
526
+ if (innerResult) {
527
+ return innerResult;
528
+ }
529
+ }
530
+ }
520
531
  }
521
532
  if (ast.types.length > 0) {
522
- return toGraphQLTypeWithRegistry(S__namespace.make(ast.types[0]), ctx);
533
+ return toGraphQLTypeWithRegistry(S2__namespace.make(ast.types[0]), ctx);
523
534
  }
524
- return toGraphQLType(S__namespace.make(ast));
535
+ return toGraphQLType(S2__namespace.make(ast));
525
536
  }
526
537
  function findEnumForLiteralUnion(types, ctx) {
527
538
  const literalValues = types.map((t) => String(t.literal)).sort();
@@ -564,15 +575,15 @@ function findEnumForLiteral(ast, ctx) {
564
575
  }
565
576
  function handleTupleTypeAST(ast, ctx) {
566
577
  if (ast.rest && ast.rest.length > 0) {
567
- const elementSchema = S__namespace.make(ast.rest[0].type);
578
+ const elementSchema = S2__namespace.make(ast.rest[0].type);
568
579
  const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
569
580
  return new graphql.GraphQLList(elementType);
570
581
  } else if (ast.elements && ast.elements.length > 0) {
571
- const elementSchema = S__namespace.make(ast.elements[0].type);
582
+ const elementSchema = S2__namespace.make(ast.elements[0].type);
572
583
  const elementType = toGraphQLTypeWithRegistry(elementSchema, ctx);
573
584
  return new graphql.GraphQLList(elementType);
574
585
  }
575
- return toGraphQLType(S__namespace.make(ast));
586
+ return toGraphQLType(S2__namespace.make(ast));
576
587
  }
577
588
  function schemaToFields(schema, ctx) {
578
589
  let ast = schema.ast;
@@ -596,7 +607,7 @@ function schemaToFields(schema, ctx) {
596
607
  for (const field2 of ast.propertySignatures) {
597
608
  const fieldName = String(field2.name);
598
609
  if (fieldName === "_tag") continue;
599
- const fieldSchema = S__namespace.make(field2.type);
610
+ const fieldSchema = S2__namespace.make(field2.type);
600
611
  let fieldType = toGraphQLTypeWithRegistry(fieldSchema, ctx);
601
612
  if (!field2.isOptional) {
602
613
  fieldType = getNonNull(fieldType);
@@ -617,7 +628,7 @@ function schemaToInputFields(schema, enumRegistry, inputRegistry, inputs, enums,
617
628
  for (const field2 of ast.propertySignatures) {
618
629
  const fieldName = String(field2.name);
619
630
  if (fieldName === "_tag") continue;
620
- const fieldSchema = S__namespace.make(field2.type);
631
+ const fieldSchema = S2__namespace.make(field2.type);
621
632
  let fieldType = toGraphQLInputTypeWithRegistry(
622
633
  fieldSchema,
623
634
  enumRegistry,
@@ -698,10 +709,28 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
698
709
  if (result) return result;
699
710
  }
700
711
  }
712
+ if (memberAst._tag === "TypeLiteral") {
713
+ const valueField = memberAst.propertySignatures?.find(
714
+ (p) => String(p.name) === "value"
715
+ );
716
+ if (valueField) {
717
+ const innerResult = toGraphQLInputTypeWithRegistry(
718
+ S2__namespace.make(valueField.type),
719
+ enumRegistry,
720
+ inputRegistry,
721
+ inputs,
722
+ enums,
723
+ cache
724
+ );
725
+ if (innerResult) {
726
+ return innerResult;
727
+ }
728
+ }
729
+ }
701
730
  }
702
731
  }
703
732
  return toGraphQLInputTypeWithRegistry(
704
- S__namespace.make(toAst),
733
+ S2__namespace.make(toAst),
705
734
  enumRegistry,
706
735
  inputRegistry,
707
736
  inputs,
@@ -714,7 +743,7 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
714
743
  const nonUndefinedTypes = unionAst.types.filter((t) => t._tag !== "UndefinedKeyword");
715
744
  if (nonUndefinedTypes.length === 1 && nonUndefinedTypes[0]._tag === "Union") {
716
745
  return toGraphQLInputTypeWithRegistry(
717
- S__namespace.make(nonUndefinedTypes[0]),
746
+ S2__namespace.make(nonUndefinedTypes[0]),
718
747
  enumRegistry,
719
748
  inputRegistry,
720
749
  inputs,
@@ -724,7 +753,7 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
724
753
  }
725
754
  if (nonUndefinedTypes.length === 1 && nonUndefinedTypes[0]._tag === "TypeLiteral") {
726
755
  return toGraphQLInputTypeWithRegistry(
727
- S__namespace.make(nonUndefinedTypes[0]),
756
+ S2__namespace.make(nonUndefinedTypes[0]),
728
757
  enumRegistry,
729
758
  inputRegistry,
730
759
  inputs,
@@ -746,6 +775,24 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
746
775
  if (result) return result;
747
776
  }
748
777
  }
778
+ if (memberAst._tag === "TypeLiteral") {
779
+ const valueField = memberAst.propertySignatures?.find(
780
+ (p) => String(p.name) === "value"
781
+ );
782
+ if (valueField) {
783
+ const innerResult = toGraphQLInputTypeWithRegistry(
784
+ S2__namespace.make(valueField.type),
785
+ enumRegistry,
786
+ inputRegistry,
787
+ inputs,
788
+ enums,
789
+ cache
790
+ );
791
+ if (innerResult) {
792
+ return innerResult;
793
+ }
794
+ }
795
+ }
749
796
  }
750
797
  const allLiterals = unionAst.types.every((t) => t._tag === "Literal");
751
798
  if (allLiterals) {
@@ -779,7 +826,7 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
779
826
  if (ast._tag === "Suspend") {
780
827
  const innerAst = ast.f();
781
828
  return toGraphQLInputTypeWithRegistry(
782
- S__namespace.make(innerAst),
829
+ S2__namespace.make(innerAst),
783
830
  enumRegistry,
784
831
  inputRegistry,
785
832
  inputs,
@@ -796,7 +843,7 @@ function toGraphQLArgsWithRegistry(schema, enumRegistry, inputRegistry, inputs,
796
843
  for (const field2 of ast.propertySignatures) {
797
844
  const fieldName = String(field2.name);
798
845
  if (fieldName === "_tag") continue;
799
- const fieldSchema = S__namespace.make(field2.type);
846
+ const fieldSchema = S2__namespace.make(field2.type);
800
847
  let fieldType = toGraphQLInputTypeWithRegistry(
801
848
  fieldSchema,
802
849
  enumRegistry,
@@ -833,7 +880,7 @@ function isOptionSchema(schema) {
833
880
  }
834
881
  function encodeResolverOutput(schema, value) {
835
882
  if (isOptionSchema(schema)) {
836
- return effect.Effect.orDie(S__namespace.encode(schema)(value));
883
+ return effect.Effect.orDie(S2__namespace.encode(schema)(value));
837
884
  }
838
885
  return effect.Effect.succeed(value);
839
886
  }