@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.js
CHANGED
|
@@ -240,6 +240,14 @@ function buildReverseLookups(ctx) {
|
|
|
240
240
|
for (const [typeName, typeReg] of ctx.types) {
|
|
241
241
|
ctx.schemaToTypeName.set(typeReg.schema, typeName);
|
|
242
242
|
ctx.astToTypeName.set(typeReg.schema.ast, typeName);
|
|
243
|
+
let ast = typeReg.schema.ast;
|
|
244
|
+
while (ast._tag === "Transformation") {
|
|
245
|
+
ast = ast.to;
|
|
246
|
+
ctx.astToTypeName.set(ast, typeName);
|
|
247
|
+
}
|
|
248
|
+
if (ast._tag === "Declaration" && ast.typeParameters?.[0]) {
|
|
249
|
+
ctx.astToTypeName.set(ast.typeParameters[0], typeName);
|
|
250
|
+
}
|
|
243
251
|
}
|
|
244
252
|
}
|
|
245
253
|
if (!ctx.schemaToInterfaceName) {
|
|
@@ -248,6 +256,14 @@ function buildReverseLookups(ctx) {
|
|
|
248
256
|
for (const [interfaceName, interfaceReg] of ctx.interfaces) {
|
|
249
257
|
ctx.schemaToInterfaceName.set(interfaceReg.schema, interfaceName);
|
|
250
258
|
ctx.astToInterfaceName.set(interfaceReg.schema.ast, interfaceName);
|
|
259
|
+
let ast = interfaceReg.schema.ast;
|
|
260
|
+
while (ast._tag === "Transformation") {
|
|
261
|
+
ast = ast.to;
|
|
262
|
+
ctx.astToInterfaceName.set(ast, interfaceName);
|
|
263
|
+
}
|
|
264
|
+
if (ast._tag === "Declaration" && ast.typeParameters?.[0]) {
|
|
265
|
+
ctx.astToInterfaceName.set(ast.typeParameters[0], interfaceName);
|
|
266
|
+
}
|
|
251
267
|
}
|
|
252
268
|
}
|
|
253
269
|
if (!ctx.schemaToInputName) {
|
|
@@ -256,6 +272,14 @@ function buildReverseLookups(ctx) {
|
|
|
256
272
|
for (const [inputName, inputReg] of ctx.inputs) {
|
|
257
273
|
ctx.schemaToInputName.set(inputReg.schema, inputName);
|
|
258
274
|
ctx.astToInputName.set(inputReg.schema.ast, inputName);
|
|
275
|
+
let ast = inputReg.schema.ast;
|
|
276
|
+
while (ast._tag === "Transformation") {
|
|
277
|
+
ast = ast.to;
|
|
278
|
+
ctx.astToInputName.set(ast, inputName);
|
|
279
|
+
}
|
|
280
|
+
if (ast._tag === "Declaration" && ast.typeParameters?.[0]) {
|
|
281
|
+
ctx.astToInputName.set(ast.typeParameters[0], inputName);
|
|
282
|
+
}
|
|
259
283
|
}
|
|
260
284
|
}
|
|
261
285
|
if (!ctx.enumSortedValues) {
|
|
@@ -360,7 +384,27 @@ function getOptionInnerType2(ast) {
|
|
|
360
384
|
}
|
|
361
385
|
function handleTransformationAST(ast, ctx) {
|
|
362
386
|
const toAst = ast.to;
|
|
387
|
+
const fromAst = ast.from;
|
|
363
388
|
if (isOptionDeclaration2(toAst)) {
|
|
389
|
+
if (fromAst && fromAst._tag === "Union") {
|
|
390
|
+
for (const memberAst of fromAst.types) {
|
|
391
|
+
if (memberAst._tag === "Literal") continue;
|
|
392
|
+
if (memberAst._tag === "UndefinedKeyword") continue;
|
|
393
|
+
const typeName = ctx.astToTypeName?.get(memberAst);
|
|
394
|
+
if (typeName) {
|
|
395
|
+
const result = ctx.typeRegistry.get(typeName);
|
|
396
|
+
if (result) return result;
|
|
397
|
+
}
|
|
398
|
+
if (memberAst._tag === "Transformation") {
|
|
399
|
+
const innerToAst = memberAst.to;
|
|
400
|
+
const transformedTypeName = ctx.astToTypeName?.get(innerToAst);
|
|
401
|
+
if (transformedTypeName) {
|
|
402
|
+
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
403
|
+
if (result) return result;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
364
408
|
const innerType = getOptionInnerType2(toAst);
|
|
365
409
|
if (innerType) {
|
|
366
410
|
return toGraphQLTypeWithRegistry(S.make(innerType), ctx);
|
|
@@ -388,6 +432,21 @@ function handleUnionAST(ast, ctx) {
|
|
|
388
432
|
const unionType2 = findRegisteredUnion(ast.types, ctx);
|
|
389
433
|
if (unionType2) return unionType2;
|
|
390
434
|
}
|
|
435
|
+
for (const memberAst of ast.types) {
|
|
436
|
+
const typeName = ctx.astToTypeName?.get(memberAst);
|
|
437
|
+
if (typeName) {
|
|
438
|
+
const result = ctx.typeRegistry.get(typeName);
|
|
439
|
+
if (result) return result;
|
|
440
|
+
}
|
|
441
|
+
if (memberAst._tag === "Transformation") {
|
|
442
|
+
const toAst = memberAst.to;
|
|
443
|
+
const transformedTypeName = ctx.astToTypeName?.get(toAst);
|
|
444
|
+
if (transformedTypeName) {
|
|
445
|
+
const result = ctx.typeRegistry.get(transformedTypeName);
|
|
446
|
+
if (result) return result;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
391
450
|
if (ast.types.length > 0) {
|
|
392
451
|
return toGraphQLTypeWithRegistry(S.make(ast.types[0]), ctx);
|
|
393
452
|
}
|
|
@@ -515,6 +574,14 @@ function buildInputTypeLookupCache(inputs, enums) {
|
|
|
515
574
|
for (const [inputName, inputReg] of inputs) {
|
|
516
575
|
cache.schemaToInputName.set(inputReg.schema, inputName);
|
|
517
576
|
cache.astToInputName.set(inputReg.schema.ast, inputName);
|
|
577
|
+
let ast = inputReg.schema.ast;
|
|
578
|
+
while (ast._tag === "Transformation") {
|
|
579
|
+
ast = ast.to;
|
|
580
|
+
cache.astToInputName.set(ast, inputName);
|
|
581
|
+
}
|
|
582
|
+
if (ast._tag === "Declaration" && ast.typeParameters?.[0]) {
|
|
583
|
+
cache.astToInputName.set(ast.typeParameters[0], inputName);
|
|
584
|
+
}
|
|
518
585
|
}
|
|
519
586
|
for (const [enumName, enumReg] of enums) {
|
|
520
587
|
cache.enumSortedValues.set(enumName, [...enumReg.values].sort());
|
|
@@ -542,6 +609,26 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
542
609
|
}
|
|
543
610
|
if (ast._tag === "Transformation") {
|
|
544
611
|
const toAst = ast.to;
|
|
612
|
+
const fromAst = ast.from;
|
|
613
|
+
if (isOptionDeclaration2(toAst) && fromAst && fromAst._tag === "Union") {
|
|
614
|
+
for (const memberAst of fromAst.types) {
|
|
615
|
+
if (memberAst._tag === "Literal") continue;
|
|
616
|
+
if (memberAst._tag === "UndefinedKeyword") continue;
|
|
617
|
+
const inputName = cache?.astToInputName?.get(memberAst);
|
|
618
|
+
if (inputName) {
|
|
619
|
+
const result = inputRegistry.get(inputName);
|
|
620
|
+
if (result) return result;
|
|
621
|
+
}
|
|
622
|
+
if (memberAst._tag === "Transformation") {
|
|
623
|
+
const innerToAst = memberAst.to;
|
|
624
|
+
const transformedInputName = cache?.astToInputName?.get(innerToAst);
|
|
625
|
+
if (transformedInputName) {
|
|
626
|
+
const result = inputRegistry.get(transformedInputName);
|
|
627
|
+
if (result) return result;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
545
632
|
return toGraphQLInputTypeWithRegistry(
|
|
546
633
|
S.make(toAst),
|
|
547
634
|
enumRegistry,
|
|
@@ -574,6 +661,21 @@ function toGraphQLInputTypeWithRegistry(schema, enumRegistry, inputRegistry, inp
|
|
|
574
661
|
cache
|
|
575
662
|
);
|
|
576
663
|
}
|
|
664
|
+
for (const memberAst of unionAst.types) {
|
|
665
|
+
const inputName = cache?.astToInputName?.get(memberAst);
|
|
666
|
+
if (inputName) {
|
|
667
|
+
const result = inputRegistry.get(inputName);
|
|
668
|
+
if (result) return result;
|
|
669
|
+
}
|
|
670
|
+
if (memberAst._tag === "Transformation") {
|
|
671
|
+
const toAst = memberAst.to;
|
|
672
|
+
const transformedInputName = cache?.astToInputName?.get(toAst);
|
|
673
|
+
if (transformedInputName) {
|
|
674
|
+
const result = inputRegistry.get(transformedInputName);
|
|
675
|
+
if (result) return result;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
}
|
|
577
679
|
const allLiterals = unionAst.types.every((t) => t._tag === "Literal");
|
|
578
680
|
if (allLiterals) {
|
|
579
681
|
const literalValues = unionAst.types.map((t) => String(t.literal)).sort();
|