edgedb / edgedb-js

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

Illegal type union on `isActive` even though that property isn't selected #717

Open anubra266 opened 10 months ago

anubra266 commented 10 months ago

I get this image

This is my query. isActive is a computed property on Membership type. I'm doing memberships because it's a multi link on User to the Membership type Membership is an abstract type, and OrgMembership is a polymorphic type that extends it

image

This is the generated edheQl

std::assert_single((WITH
  __scope_0_defaultUser := DETACHED default::User
SELECT __scope_0_defaultUser {
  created_at,
  email,
  updated_at,
  id,
  memberships := (
    WITH
      __scope_1_defaultMembership := __scope_0_defaultUser.memberships
    SELECT __scope_1_defaultMembership {
      [IS default::OrgMembership].role
    }
  )
}
FILTER (__scope_0_defaultUser.id = <std::uuid>"0a010d08-3484-11ee-9380-f3c6acf82edf")))

User type image

Abstract membership type image

OrgMembership type image

jackfischer commented 10 months ago

There is something peculiar with properties named isActive via QB. We get an error thrown at toEdgeQL on a simple select of an object including isActive: true.

[cause]: Error: Field "isActive" does not exist in default::User
      at shapeToEdgeQL (webpack-internal:///(api)/./dbschema/edgeql-js/toEdgeQL.mjs:709:23)
      at renderEdgeQL (webpack-internal:///(api)/./dbschema/edgeql-js/toEdgeQL.mjs:498:28)
      at Proxy.$toEdgeQL (webpack-internal:///(api)/./dbschema/edgeql-js/toEdgeQL.mjs:125:18)
      at Proxy.$queryFunc (webpack-internal:///(api)/./dbschema/edgeql-js/query.mjs:31:24)

Bizarrely, isActive does not show up on ["*"] for the object either.

Everything works as expected in EdgeQL. Move this to the JS repo @raddevon?

jackfischer commented 10 months ago

Now seeing similar behavior with a computed boolean with a different name on a different object. So it is not the name isActive but perhaps something about booleans? But we've used booleans in countless places w/o issue. Really at a loss here.