@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/builder/index.cjs
CHANGED
|
@@ -262,6 +262,14 @@ function buildReverseLookups(ctx) {
|
|
|
262
262
|
for (const [typeName, typeReg] of ctx.types) {
|
|
263
263
|
ctx.schemaToTypeName.set(typeReg.schema, typeName);
|
|
264
264
|
ctx.astToTypeName.set(typeReg.schema.ast, typeName);
|
|
265
|
+
let ast = typeReg.schema.ast;
|
|
266
|
+
while (ast._tag === "Transformation") {
|
|
267
|
+
ast = ast.to;
|
|
268
|
+
ctx.astToTypeName.set(ast, typeName);
|
|
269
|
+
}
|
|
270
|
+
if (ast._tag === "Declaration" && ast.typeParameters?.[0]) {
|
|
271
|
+
ctx.astToTypeName.set(ast.typeParameters[0], typeName);
|
|
272
|
+
}
|
|
265
273
|
}
|
|
266
274
|
}
|
|
267
275
|
if (!ctx.schemaToInterfaceName) {
|
|
@@ -270,6 +278,14 @@ function buildReverseLookups(ctx) {
|
|
|
270
278
|
for (const [interfaceName, interfaceReg] of ctx.interfaces) {
|
|
271
279
|
ctx.schemaToInterfaceName.set(interfaceReg.schema, interfaceName);
|
|
272
280
|
ctx.astToInterfaceName.set(interfaceReg.schema.ast, interfaceName);
|
|
281
|
+
let ast = interfaceReg.schema.ast;
|
|
282
|
+
while (ast._tag === "Transformation") {
|
|
283
|
+
ast = ast.to;
|
|
284
|
+
ctx.astToInterfaceName.set(ast, interfaceName);
|
|
285
|
+
}
|
|
286
|
+
if (ast._tag === "Declaration" && ast.typeParameters?.[0]) {
|
|
287
|
+
ctx.astToInterfaceName.set(ast.typeParameters[0], interfaceName);
|
|
288
|
+
}
|
|
273
289
|
}
|
|
274
290
|
}
|
|
275
291
|
if (!ctx.schemaToInputName) {
|
|
@@ -278,6 +294,14 @@ function buildReverseLookups(ctx) {
|
|
|
278
294
|
for (const [inputName, inputReg] of ctx.inputs) {
|
|
279
295
|
ctx.schemaToInputName.set(inputReg.schema, inputName);
|
|
280
296
|
ctx.astToInputName.set(inputReg.schema.ast, inputName);
|
|
297
|
+
let ast = inputReg.schema.ast;
|
|
298
|
+
while (ast._tag === "Transformation") {
|
|
299
|
+
ast = ast.to;
|
|
300
|
+
ctx.astToInputName.set(ast, inputName);
|
|
301
|
+
}
|
|
302
|
+
if (ast._tag === "Declaration" && ast.typeParameters?.[0]) {
|
|
303
|
+
ctx.astToInputName.set(ast.typeParameters[0], inputName);
|
|
304
|
+
}
|
|
281
305
|
}
|
|
282
306
|
}
|
|
283
307
|
if (!ctx.enumSortedValues) {
|
|
@@ -382,7 +406,27 @@ function getOptionInnerType2(ast) {
|
|
|
382
406
|
}
|
|
383
407
|
function handleTransformationAST(ast, ctx) {
|
|
384
408
|
const toAst = ast.to;
|
|
409
|
+
const fromAst = ast.from;
|
|
385
410
|
if (isOptionDeclaration2(toAst)) {
|
|
411
|
+
if (fromAst && fromAst._tag === "Union") {
|
|
412
|
+
for (const memberAst of fromAst.types) {
|
|
413
|
+
if (memberAst._tag === "Literal") continue;
|
|
414
|
+
if (memberAst._tag === "UndefinedKeyword") continue;
|
|
415
|
+
const typeName = ctx.astToTypeName?.get(memberAst);
|
|
416
|
+
if (typeName) {
|
|
417
|
+
const result = ctx.typeRegistry.get(typeName);
|
|
418
|
+
if (result) return result;
|
|
419
|
+
}
|
|
420
|
+
if (memberAst._tag === "Transformation") {
|
|
421
|
+
const innerToAst = memberAst.to;
|
|
422
|
+
const transformedTypeName = ctx.astToTypeName?.get(innerToAst);
|
|
423
|
+
if (transformedTypeName) {
|
|
424
|
+
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
425
|
+
if (result) return result;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
386
430
|
const innerType = getOptionInnerType2(toAst);
|
|
387
431
|
if (innerType) {
|
|
388
432
|
return toGraphQLTypeWithRegistry(S__namespace.make(innerType), ctx);
|
|
@@ -410,6 +454,21 @@ function handleUnionAST(ast, ctx) {
|
|
|
410
454
|
const unionType2 = findRegisteredUnion(ast.types, ctx);
|
|
411
455
|
if (unionType2) return unionType2;
|
|
412
456
|
}
|
|
457
|
+
for (const memberAst of ast.types) {
|
|
458
|
+
const typeName = ctx.astToTypeName?.get(memberAst);
|
|
459
|
+
if (typeName) {
|
|
460
|
+
const result = ctx.typeRegistry.get(typeName);
|
|
461
|
+
if (result) return result;
|
|
462
|
+
}
|
|
463
|
+
if (memberAst._tag === "Transformation") {
|
|
464
|
+
const toAst = memberAst.to;
|
|
465
|
+
const transformedTypeName = ctx.astToTypeName?.get(toAst);
|
|
466
|
+
if (transformedTypeName) {
|
|
467
|
+
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
468
|
+
if (result) return result;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
413
472
|
if (ast.types.length > 0) {
|
|
414
473
|
return toGraphQLTypeWithRegistry(S__namespace.make(ast.types[0]), ctx);
|
|
415
474
|
}
|
|
@@ -537,6 +596,14 @@ function buildInputTypeLookupCache(inputs, enums) {
|
|
|
537
596
|
for (const [inputName, inputReg] of inputs) {
|
|
538
597
|
cache.schemaToInputName.set(inputReg.schema, inputName);
|
|
539
598
|
cache.astToInputName.set(inputReg.schema.ast, inputName);
|
|
599
|
+
let ast = inputReg.schema.ast;
|
|
600
|
+
while (ast._tag === "Transformation") {
|
|
601
|
+
ast = ast.to;
|
|
602
|
+
cache.astToInputName.set(ast, inputName);
|
|
603
|
+
}
|
|
604
|
+
if (ast._tag === "Declaration" && ast.typeParameters?.[0]) {
|
|
605
|
+
cache.astToInputName.set(ast.typeParameters[0], inputName);
|
|
606
|
+
}
|
|
540
607
|
}
|
|
541
608
|
for (const [enumName, enumReg] of enums) {
|
|
542
609
|
cache.enumSortedValues.set(enumName, [...enumReg.values].sort());
|
|
@@ -564,6 +631,26 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
564
631
|
}
|
|
565
632
|
if (ast._tag === "Transformation") {
|
|
566
633
|
const toAst = ast.to;
|
|
634
|
+
const fromAst = ast.from;
|
|
635
|
+
if (isOptionDeclaration2(toAst) && fromAst && fromAst._tag === "Union") {
|
|
636
|
+
for (const memberAst of fromAst.types) {
|
|
637
|
+
if (memberAst._tag === "Literal") continue;
|
|
638
|
+
if (memberAst._tag === "UndefinedKeyword") continue;
|
|
639
|
+
const inputName = cache?.astToInputName?.get(memberAst);
|
|
640
|
+
if (inputName) {
|
|
641
|
+
const result = inputRegistry.get(inputName);
|
|
642
|
+
if (result) return result;
|
|
643
|
+
}
|
|
644
|
+
if (memberAst._tag === "Transformation") {
|
|
645
|
+
const innerToAst = memberAst.to;
|
|
646
|
+
const transformedInputName = cache?.astToInputName?.get(innerToAst);
|
|
647
|
+
if (transformedInputName) {
|
|
648
|
+
const result = inputRegistry.get(transformedInputName);
|
|
649
|
+
if (result) return result;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
567
654
|
return toGraphQLInputTypeWithRegistry(
|
|
568
655
|
S__namespace.make(toAst),
|
|
569
656
|
enumRegistry,
|
|
@@ -596,6 +683,21 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
596
683
|
cache
|
|
597
684
|
);
|
|
598
685
|
}
|
|
686
|
+
for (const memberAst of unionAst.types) {
|
|
687
|
+
const inputName = cache?.astToInputName?.get(memberAst);
|
|
688
|
+
if (inputName) {
|
|
689
|
+
const result = inputRegistry.get(inputName);
|
|
690
|
+
if (result) return result;
|
|
691
|
+
}
|
|
692
|
+
if (memberAst._tag === "Transformation") {
|
|
693
|
+
const toAst = memberAst.to;
|
|
694
|
+
const transformedInputName = cache?.astToInputName?.get(toAst);
|
|
695
|
+
if (transformedInputName) {
|
|
696
|
+
const result = inputRegistry.get(transformedInputName);
|
|
697
|
+
if (result) return result;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
599
701
|
const allLiterals = unionAst.types.every((t) => t._tag === "Literal");
|
|
600
702
|
if (allLiterals) {
|
|
601
703
|
const literalValues = unionAst.types.map((t) => String(t.literal)).sort();
|