geldata / geldata/gel-python

Backlinks and type filter operator in ORM

Open
#671 2 comments 0 reactions 1 assignee Claimed by @dnwpark View on GitHub
ORM
Dominant language
Python
Stars
415
Forks
50
PR merge metrics
No merged PRs in 30d

Description

We need a way to access backlinks in ORM. As we know the backlinks need a name and a source type to be properly defined. However in pure EdgeQL we allow bare backlinks (which then get inferred as `Object` type) and we treat the backlink `.<` operator separate from type filtering `[is Foo]`.

Should we have `__backlink__` available in Python? Do we pass the type as an argument?
```python
q = default.User.filter(lambda u: u.__backlink__.members(default.Group).name = 'admin')
```
Will we have some kind of separate type filter operator exposed in Python? Can I translate something like:
```edgeql
select User {
name,
# assume the schema has type Bot extending User
special := .friends[is Bot],
}
```
It could be `std.is_type(...)` maybe? Would that mean that backlinks then become something like: `std.is_type(u.__backlink__.friends, default.Bot)` or `std.is_type(u.__backlink__.members, default.Group)`?

Ideally, I'd prefer not to pollute the plain fields of reflected types with all the backlinks directly, hence the `__backlink__` intermediary.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.