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

Link properties in backlink.

Open izakfilmalter opened this issue 1 year ago • 3 comments

Right now you can't get link properties from a backlink. This means you can't filter the backlink, or grab data from that edge. I am not sure if this an actual limitation of EdgeDB, or just a limitation of the library.

image

This leads to querres that look like this:

e.select(e.User, (x) => ({
  filter: e.op(x.id, '=', e.uuid(userId)),
  friends: (y) => ({
    filter: e.op(
      e.op(y['@status'], '=', e.Status.accepted),
      'and',
      e.op('exists', y.name),
    ),
  }),
  receivedFriends: e.select(x['<friends[is User]'], (y) => ({
    friends: (z) => ({
      filter: e.op(z.id, '=', e.uuid(userId)),
      '@status': true,
    }),
  })),
}))

You then have to filter this on the client side.

izakfilmalter avatar Jul 29 '22 12:07 izakfilmalter

This is a tricky one. It's a limitation of EdgeQL currently, and I can't find a simpler workaround than the one you're currently using. I suspect you'd have an easier time using an intermediate table to represent friendships - link properties can be fiddly and they're subject to certain limitations (e.g. can't be required). I'll starting thinking about an API to make this better at the query builder level.

colinhacks avatar Jul 29 '22 18:07 colinhacks

It's a limitation of EdgeQL currently

I thought linkprops on backlinks got fixed (https://github.com/edgedb/edgedb/pull/3841), or does this not work with how the qb generates queries?

jaclarke avatar Jul 29 '22 18:07 jaclarke

Ya I have been thinking about dumping the ink properties because they aren't as real as other properties. I really like the idea of storing data on an edge and not having to deal with another id.

izakfilmalter avatar Jul 29 '22 20:07 izakfilmalter