@effect-gql/core 1.4.1 → 1.4.3
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 +102 -0
- package/builder/index.cjs.map +1 -1
- package/builder/index.js +102 -0
- package/builder/index.js.map +1 -1
- package/index.cjs +102 -0
- package/index.cjs.map +1 -1
- package/index.js +102 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -286,6 +286,14 @@ function buildReverseLookups(ctx) {
|
|
|
286
286
|
for (const [typeName, typeReg] of ctx.types) {
|
|
287
287
|
ctx.schemaToTypeName.set(typeReg.schema, typeName);
|
|
288
288
|
ctx.astToTypeName.set(typeReg.schema.ast, typeName);
|
|
289
|
+
let ast = typeReg.schema.ast;
|
|
290
|
+
while (ast._tag === "Transformation") {
|
|
291
|
+
ast = ast.to;
|
|
292
|
+
ctx.astToTypeName.set(ast, typeName);
|
|
293
|
+
}
|
|
294
|
+
if (ast._tag === "Declaration" && ast.typeParameters?.[0]) {
|
|
295
|
+
ctx.astToTypeName.set(ast.typeParameters[0], typeName);
|
|
296
|
+
}
|
|
289
297
|
}
|
|
290
298
|
}
|
|
291
299
|
if (!ctx.schemaToInterfaceName) {
|
|
@@ -294,6 +302,14 @@ function buildReverseLookups(ctx) {
|
|
|
294
302
|
for (const [interfaceName, interfaceReg] of ctx.interfaces) {
|
|
295
303
|
ctx.schemaToInterfaceName.set(interfaceReg.schema, interfaceName);
|
|
296
304
|
ctx.astToInterfaceName.set(interfaceReg.schema.ast, interfaceName);
|
|
305
|
+
let ast = interfaceReg.schema.ast;
|
|
306
|
+
while (ast._tag === "Transformation") {
|
|
307
|
+
ast = ast.to;
|
|
308
|
+
ctx.astToInterfaceName.set(ast, interfaceName);
|
|
309
|
+
}
|
|
310
|
+
if (ast._tag === "Declaration" && ast.typeParameters?.[0]) {
|
|
311
|
+
ctx.astToInterfaceName.set(ast.typeParameters[0], interfaceName);
|
|
312
|
+
}
|
|
297
313
|
}
|
|
298
314
|
}
|
|
299
315
|
if (!ctx.schemaToInputName) {
|
|
@@ -302,6 +318,14 @@ function buildReverseLookups(ctx) {
|
|
|
302
318
|
for (const [inputName, inputReg] of ctx.inputs) {
|
|
303
319
|
ctx.schemaToInputName.set(inputReg.schema, inputName);
|
|
304
320
|
ctx.astToInputName.set(inputReg.schema.ast, inputName);
|
|
321
|
+
let ast = inputReg.schema.ast;
|
|
322
|
+
while (ast._tag === "Transformation") {
|
|
323
|
+
ast = ast.to;
|
|
324
|
+
ctx.astToInputName.set(ast, inputName);
|
|
325
|
+
}
|
|
326
|
+
if (ast._tag === "Declaration" && ast.typeParameters?.[0]) {
|
|
327
|
+
ctx.astToInputName.set(ast.typeParameters[0], inputName);
|
|
328
|
+
}
|
|
305
329
|
}
|
|
306
330
|
}
|
|
307
331
|
if (!ctx.enumSortedValues) {
|
|
@@ -406,7 +430,27 @@ function getOptionInnerType2(ast) {
|
|
|
406
430
|
}
|
|
407
431
|
function handleTransformationAST(ast, ctx) {
|
|
408
432
|
const toAst = ast.to;
|
|
433
|
+
const fromAst = ast.from;
|
|
409
434
|
if (isOptionDeclaration2(toAst)) {
|
|
435
|
+
if (fromAst && fromAst._tag === "Union") {
|
|
436
|
+
for (const memberAst of fromAst.types) {
|
|
437
|
+
if (memberAst._tag === "Literal") continue;
|
|
438
|
+
if (memberAst._tag === "UndefinedKeyword") continue;
|
|
439
|
+
const typeName = ctx.astToTypeName?.get(memberAst);
|
|
440
|
+
if (typeName) {
|
|
441
|
+
const result = ctx.typeRegistry.get(typeName);
|
|
442
|
+
if (result) return result;
|
|
443
|
+
}
|
|
444
|
+
if (memberAst._tag === "Transformation") {
|
|
445
|
+
const innerToAst = memberAst.to;
|
|
446
|
+
const transformedTypeName = ctx.astToTypeName?.get(innerToAst);
|
|
447
|
+
if (transformedTypeName) {
|
|
448
|
+
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
449
|
+
if (result) return result;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
410
454
|
const innerType = getOptionInnerType2(toAst);
|
|
411
455
|
if (innerType) {
|
|
412
456
|
return toGraphQLTypeWithRegistry(S.make(innerType), ctx);
|
|
@@ -434,6 +478,21 @@ function handleUnionAST(ast, ctx) {
|
|
|
434
478
|
const unionType2 = findRegisteredUnion(ast.types, ctx);
|
|
435
479
|
if (unionType2) return unionType2;
|
|
436
480
|
}
|
|
481
|
+
for (const memberAst of ast.types) {
|
|
482
|
+
const typeName = ctx.astToTypeName?.get(memberAst);
|
|
483
|
+
if (typeName) {
|
|
484
|
+
const result = ctx.typeRegistry.get(typeName);
|
|
485
|
+
if (result) return result;
|
|
486
|
+
}
|
|
487
|
+
if (memberAst._tag === "Transformation") {
|
|
488
|
+
const toAst = memberAst.to;
|
|
489
|
+
const transformedTypeName = ctx.astToTypeName?.get(toAst);
|
|
490
|
+
if (transformedTypeName) {
|
|
491
|
+
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
492
|
+
if (result) return result;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
437
496
|
if (ast.types.length > 0) {
|
|
438
497
|
return toGraphQLTypeWithRegistry(S.make(ast.types[0]), ctx);
|
|
439
498
|
}
|
|
@@ -561,6 +620,14 @@ function buildInputTypeLookupCache(inputs, enums) {
|
|
|
561
620
|
for (const [inputName, inputReg] of inputs) {
|
|
562
621
|
cache.schemaToInputName.set(inputReg.schema, inputName);
|
|
563
622
|
cache.astToInputName.set(inputReg.schema.ast, inputName);
|
|
623
|
+
let ast = inputReg.schema.ast;
|
|
624
|
+
while (ast._tag === "Transformation") {
|
|
625
|
+
ast = ast.to;
|
|
626
|
+
cache.astToInputName.set(ast, inputName);
|
|
627
|
+
}
|
|
628
|
+
if (ast._tag === "Declaration" && ast.typeParameters?.[0]) {
|
|
629
|
+
cache.astToInputName.set(ast.typeParameters[0], inputName);
|
|
630
|
+
}
|
|
564
631
|
}
|
|
565
632
|
for (const [enumName, enumReg] of enums) {
|
|
566
633
|
cache.enumSortedValues.set(enumName, [...enumReg.values].sort());
|
|
@@ -588,6 +655,26 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
588
655
|
}
|
|
589
656
|
if (ast._tag === "Transformation") {
|
|
590
657
|
const toAst = ast.to;
|
|
658
|
+
const fromAst = ast.from;
|
|
659
|
+
if (isOptionDeclaration2(toAst) && fromAst && fromAst._tag === "Union") {
|
|
660
|
+
for (const memberAst of fromAst.types) {
|
|
661
|
+
if (memberAst._tag === "Literal") continue;
|
|
662
|
+
if (memberAst._tag === "UndefinedKeyword") continue;
|
|
663
|
+
const inputName = cache?.astToInputName?.get(memberAst);
|
|
664
|
+
if (inputName) {
|
|
665
|
+
const result = inputRegistry.get(inputName);
|
|
666
|
+
if (result) return result;
|
|
667
|
+
}
|
|
668
|
+
if (memberAst._tag === "Transformation") {
|
|
669
|
+
const innerToAst = memberAst.to;
|
|
670
|
+
const transformedInputName = cache?.astToInputName?.get(innerToAst);
|
|
671
|
+
if (transformedInputName) {
|
|
672
|
+
const result = inputRegistry.get(transformedInputName);
|
|
673
|
+
if (result) return result;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
591
678
|
return toGraphQLInputTypeWithRegistry(
|
|
592
679
|
S.make(toAst),
|
|
593
680
|
enumRegistry,
|
|
@@ -620,6 +707,21 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
620
707
|
cache
|
|
621
708
|
);
|
|
622
709
|
}
|
|
710
|
+
for (const memberAst of unionAst.types) {
|
|
711
|
+
const inputName = cache?.astToInputName?.get(memberAst);
|
|
712
|
+
if (inputName) {
|
|
713
|
+
const result = inputRegistry.get(inputName);
|
|
714
|
+
if (result) return result;
|
|
715
|
+
}
|
|
716
|
+
if (memberAst._tag === "Transformation") {
|
|
717
|
+
const toAst = memberAst.to;
|
|
718
|
+
const transformedInputName = cache?.astToInputName?.get(toAst);
|
|
719
|
+
if (transformedInputName) {
|
|
720
|
+
const result = inputRegistry.get(transformedInputName);
|
|
721
|
+
if (result) return result;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
623
725
|
const allLiterals = unionAst.types.every((t) => t._tag === "Literal");
|
|
624
726
|
if (allLiterals) {
|
|
625
727
|
const literalValues = unionAst.types.map((t) => String(t.literal)).sort();
|