Skip to content

Commit 6fbe87c

Browse files
committed
Remove part of QB type gen override
With my upstream change, the query builder correctly generates scalars with our `scalarToLiteralMapping` additions. Unfortunately, we still have to handle import fixes.
1 parent caacaf2 commit 6fbe87c

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

src/core/edgedb/generator/query-builder.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export async function generateQueryBuilder({
2222
schemaDir: 'unused',
2323
});
2424
addJsExtensionDeepPathsOfEdgedbLibrary(qbDir);
25-
changeCustomScalars(qbDir);
25+
fixCustomScalarsImports(qbDir);
2626
updateEdgeQLRenderingForOurCustomScalars(qbDir);
2727
updateCastMapsForOurCustomScalars(qbDir);
2828
changeImplicitIDType(qbDir);
@@ -42,20 +42,11 @@ function addJsExtensionDeepPathsOfEdgedbLibrary(qbDir: Directory) {
4242
}
4343
}
4444

45-
function changeCustomScalars(qbDir: Directory) {
46-
// Change $uuid scalar type alias to use ID type instead of string
45+
function fixCustomScalarsImports(qbDir: Directory) {
4746
for (const scalars of groupBy(customScalars.values(), (s) => s.module)) {
4847
const moduleFile = qbDir.addSourceFileAtPath(
4948
`modules/${scalars[0]!.module}.ts`,
5049
);
51-
for (const scalar of scalars) {
52-
const typeAlias = moduleFile.getTypeAliasOrThrow(`$${scalar.type}`);
53-
typeAlias
54-
.getFirstChildByKindOrThrow(SyntaxKind.TypeReference)
55-
.getFirstChildByKindOrThrow(SyntaxKind.SyntaxList)
56-
.getLastChildOrThrow()
57-
.replaceWithText(scalar.ts);
58-
}
5950
addCustomScalarImports(moduleFile, scalars);
6051
}
6152
}

src/core/edgedb/generator/scalars.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const customScalars = mapEntries(codecs, (codec) => [
88
]).asMap;
99

1010
export function setTsTypesFromOurScalarCodecs() {
11-
// this is used for schema interfaces
11+
// this is used for schema interfaces & query builder
1212
for (const { info } of codecs) {
1313
const fqName = `${info.module}::${info.type}`;
1414
scalarToLiteralMapping[fqName].type = info.ts;

0 commit comments

Comments
 (0)