edgedb-js icon indicating copy to clipboard operation
edgedb-js copied to clipboard

Generated edgeql TypeScript files are very slow to resolve

Open alexgorbatchev opened this issue 2 years ago • 5 comments

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

ezgif-1-1f4ace40b7

alexgorbatchev avatar Mar 01 '23 18:03 alexgorbatchev

This could be partially solved by placing generated code into separate project, and setting skipLibCheck: true, but it's inconvinient.

MrFoxPro avatar Oct 17 '23 12:10 MrFoxPro

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. :(

Shamshiel avatar Dec 09 '23 05:12 Shamshiel

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.

MrFoxPro avatar Dec 09 '23 06:12 MrFoxPro

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. :(

Shamshiel avatar Dec 09 '23 06:12 Shamshiel

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.

scotttrinh avatar Dec 12 '23 22:12 scotttrinh