@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.cjs +10 -20
- package/builder/index.cjs.map +1 -1
- package/builder/index.js +10 -20
- package/builder/index.js.map +1 -1
- package/index.cjs +12 -20
- package/index.cjs.map +1 -1
- package/index.d.cts +12 -1
- package/index.d.ts +12 -1
- package/index.js +11 -21
- package/index.js.map +1 -1
- package/package.json +1 -1
package/builder/index.cjs
CHANGED
|
@@ -79,7 +79,7 @@ function handleTupleTypeAST(ast, convertFn) {
|
|
|
79
79
|
}
|
|
80
80
|
return void 0;
|
|
81
81
|
}
|
|
82
|
-
function buildFieldsFromPropertySignatures(propertySignatures, convertFn
|
|
82
|
+
function buildFieldsFromPropertySignatures(propertySignatures, convertFn) {
|
|
83
83
|
const fields = {};
|
|
84
84
|
for (const field2 of propertySignatures) {
|
|
85
85
|
const fieldName = String(field2.name);
|
|
@@ -188,7 +188,8 @@ var toGraphQLInputType = (schema) => {
|
|
|
188
188
|
if (ast._tag === "TypeLiteral") {
|
|
189
189
|
const fields = buildFieldsFromPropertySignatures(
|
|
190
190
|
ast.propertySignatures,
|
|
191
|
-
toGraphQLInputType
|
|
191
|
+
toGraphQLInputType
|
|
192
|
+
);
|
|
192
193
|
const typeName = schema.annotations?.identifier || `Input_${Math.random().toString(36).slice(2, 11)}`;
|
|
193
194
|
return new graphql.GraphQLInputObjectType({
|
|
194
195
|
name: typeName,
|
|
@@ -348,7 +349,7 @@ function toGraphQLTypeWithRegistry(schema, ctx) {
|
|
|
348
349
|
return handleTupleTypeAST2(ast, ctx);
|
|
349
350
|
}
|
|
350
351
|
if (ast._tag === "Declaration") {
|
|
351
|
-
if (
|
|
352
|
+
if (isOptionDeclaration(ast)) {
|
|
352
353
|
const innerType = getOptionInnerType2(ast);
|
|
353
354
|
if (innerType) {
|
|
354
355
|
return toGraphQLTypeWithRegistry(S2__namespace.make(innerType), ctx);
|
|
@@ -379,19 +380,6 @@ function findRegisteredInterface(schema, ast, ctx) {
|
|
|
379
380
|
}
|
|
380
381
|
return void 0;
|
|
381
382
|
}
|
|
382
|
-
function isOptionDeclaration2(ast) {
|
|
383
|
-
if (ast._tag === "Declaration") {
|
|
384
|
-
const annotations = ast.annotations;
|
|
385
|
-
if (annotations) {
|
|
386
|
-
const TypeConstructorSymbol = /* @__PURE__ */ Symbol.for("effect/annotation/TypeConstructor");
|
|
387
|
-
const typeConstructor = annotations[TypeConstructorSymbol];
|
|
388
|
-
if (typeConstructor && typeConstructor._tag === "effect/Option") {
|
|
389
|
-
return true;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
return false;
|
|
394
|
-
}
|
|
395
383
|
function getOptionInnerType2(ast) {
|
|
396
384
|
if (ast._tag === "Declaration") {
|
|
397
385
|
const typeParams = ast.typeParameters;
|
|
@@ -492,7 +480,7 @@ function handleArrayTransformation(toAst, ctx) {
|
|
|
492
480
|
function handleTransformationAST(ast, ctx) {
|
|
493
481
|
const toAst = ast.to;
|
|
494
482
|
const fromAst = ast.from;
|
|
495
|
-
if (
|
|
483
|
+
if (isOptionDeclaration(toAst)) {
|
|
496
484
|
const optionResult = handleOptionTransformation(ast, fromAst, toAst, ctx);
|
|
497
485
|
if (optionResult) return optionResult;
|
|
498
486
|
}
|
|
@@ -598,7 +586,8 @@ function schemaToFields(schema, ctx) {
|
|
|
598
586
|
if (fieldName === "_tag") continue;
|
|
599
587
|
const fieldSchema = S2__namespace.make(field2.type);
|
|
600
588
|
let fieldType = toGraphQLTypeWithRegistry(fieldSchema, ctx);
|
|
601
|
-
|
|
589
|
+
const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
|
|
590
|
+
if (!field2.isOptional && !isOptionField) {
|
|
602
591
|
fieldType = getNonNull(fieldType);
|
|
603
592
|
}
|
|
604
593
|
fields[fieldName] = { type: fieldType };
|
|
@@ -626,7 +615,8 @@ function schemaToInputFields(schema, enumRegistry, inputRegistry, inputs, enums,
|
|
|
626
615
|
enums,
|
|
627
616
|
cache
|
|
628
617
|
);
|
|
629
|
-
|
|
618
|
+
const isOptionField = isOptionTransformation(field2.type) || isOptionDeclaration(field2.type);
|
|
619
|
+
if (!field2.isOptional && !isOptionField) {
|
|
630
620
|
fieldType = getNonNull(fieldType);
|
|
631
621
|
}
|
|
632
622
|
fields[fieldName] = { type: fieldType };
|
|
@@ -817,7 +807,7 @@ function handleOptionTransformationForInput(fromAst, toAst, inputs, inputRegistr
|
|
|
817
807
|
function handleTransformationForInput(ast, inputs, inputRegistry, enumRegistry, enums, cache) {
|
|
818
808
|
const toAst = ast.to;
|
|
819
809
|
const fromAst = ast.from;
|
|
820
|
-
if (
|
|
810
|
+
if (isOptionDeclaration(toAst)) {
|
|
821
811
|
const optionResult = handleOptionTransformationForInput(
|
|
822
812
|
fromAst,
|
|
823
813
|
toAst,
|