edgedb / edgedb-js

The official TypeScript/JS client library and query builder for EdgeDB
https://edgedb.com
Apache License 2.0
514 stars 65 forks source link

Type instantiation is excessively deep and possibly infinite.deno-ts(2589) #462

Closed ClaudiuCeia closed 1 year ago

ClaudiuCeia commented 2 years ago

Code The code causing the error.

     const query = e.delete(e.Answer, (answer) => ({
        filter: e.assert_single(
          e.op(
            e.op(
              e.op("not", e.op("exists", answer.question.quiz.permalink)),
              "and",
              e.op(answer.id, "=", e.uuid(args.id))
            ),
            "and",
            e.op(answer.question.quiz.owner.id, "=", e.uuid(user.id))
          )
        ),
      }));

Schema

Your application schema.

module default {
  type User {
    # ...properties
  }

  type Quiz {
    # ...properties
    required link owner -> User;
  }

  type Question {
    # ...properties 
    required link quiz -> Quiz;
  }

  type Answer {
    # ...properties 
    required link question -> Question;
  }
};

Generated EdgeQL

Not relevant in this case, it's just a type-level error.

Error or desired behavior

The code snippet above has a TS error: Type instantiation is excessively deep and possibly infinite.deno-ts(2589) The culprit as far as I can tell is e.assert_single, I run into this issue whenever I have non-trivial filter statements. I might also be using it wrongly, or not building the most efficient filters - but regardless, the error isn't quite that helpful.

Please note that this is happening for Deno (specifically deno 1.26.0).

Versions (please complete the following information):

Sikarii commented 2 years ago

This might be fixed with #460, I believe it has landed in the 1.x beta releases.

colinhacks commented 2 years ago

I've confirmed this is fixed. Unfortunately we haven't released the beta on deno.land/x but you can install @edgedb/generate@beta from NPM and run npx @edgedb/generate edgeql-js --target deno.