edgedb-js
edgedb-js copied to clipboard
Generated edgeql TypeScript files are very slow to resolve
Code The code causing the error.
e.app.User
Schema
module app {
abstract type WithCreatedBy {
required link createdBy -> User;
}
abstract type WithCreatedAt {
required property createdAt -> datetime {
default := (SELECT datetime_current());
readonly := true;
}
}
# -------------------------------------------------------------------------------------------------
type User extending
WithCreatedAt
{
# multi link accounts := .<users[is Account];
required property email -> str {
constraint exclusive;
}
}
type Account extending
WithCreatedAt
{
multi link users -> User;
}
abstract type WithAccount {
required link account -> Account;
}
}
Error or desired behavior
I'm observing that any time there's a generated edgeql code in currently opened file, or anywhere down the tree from currently opened file, type resolution slows down to a crawl. Generated types for some reason cause TS language server ~30s to resolve types. This happens every single time I open a file which has edgeql in it (or somewhere down the import tree).
in the screen cap below, i'm opening a file and moving mouse over one of the generated types

This could be partially solved by placing generated code into separate project, and setting skipLibCheck: true, but it's inconvinient.
Is there any progress on this or any suggestions besides the one from @MrFoxPro to resolve this performance issue? I'm basically unable to work with my project now. :(
Is there any progress on this or any suggestions besides the one from @MrFoxPro to resolve this performance issue? I'm basically unable to work with my project now. :(
You can start with raw edgedql with template literals, it's fun to write I can say, and gives you more understanding on what's going on. Plus, you will have better performance as you wouldn't need to generate queries in runtime.
Hmmm that would be a huge undertaking as I have currently 9 repositories with around 5-10 different queries each and some of them are quite complex. :(
We will be working on language server performance for our query builder first thing in the new year, but until then the suggestion about using a separate project works. You can see the TypeScript project references guide for more details there.