Open Lezek123 opened 3 years ago
From the implementation pov Solution 1 seems feasible, probably that's the way to go.
Superbly laid out @Lezek123 , and great job jumping on this so quick @dzhelezov . This feature does look a bit complex, but I can't think of anything else either.
The problem
Pioneer v2 (https://github.com/Joystream/pioneer) needs to be able to query groups of events (including multiple different types of entities) for the purpose of displaying latest activity and notifications on the platform. (ie. member's latest activity, working group latest activity, member notifications etc.)
Currently for the purpose of grouping together different types of events, the
Event
interface was created:Allowing queries like:
As described in more detail in https://github.com/Joystream/pioneer/issues/882#issuecomment-866954029, there is however a need to filter those events more specifically by relations like
member
,workingGroup
,proposal
orworker
, while only some types of events have those relationships available. This is currently not possible and any attempt to workaround this doesn't seem to work.There are a few additional, important things to consider:
OpeningFilledEvent
could be filtered either bymember
,worker
orworkingGroup
, so all of those filters should be availabe (which excludes the possibility of splittingEvent
interface into more specific interfaces)OpeningFilledEvent
, have one-to-many relationships with entities likemember
andworker
, so it should be possible to use a filter likemembers_some: { id: $memberId }
ormemberIds_includes: $memberId
.Solution 1 - allow filtering by specific type fields
The most futureproof solution would be to allow referencing interface childrens' (implementers') fields inside the interface query. I would imagine a syntax like:
Translating to a query:
Note that a filter like this would also need to be supported:
Solution 2 - support privitive arrays filtering
Because relationships doesn't yet seem to be supported by interfaces (https://github.com/Joystream/hydra/issues/359), I considered adding optional
ID
and[ID]
fields to anEvent
interface just for the purpose of filtering:This would be a bit limiting, but probably enough to support Pioneer v2 at the current stage.
The problem here is that primitive array filtering doesn't seem to be supported either, so I cannot create a query like:
(note: the array field seems to actually be represented as
Text
field in the database)Solution 3 - suppport relationships in interface
Another way to solve this would be to add support for relationships (https://github.com/Joystream/hydra/issues/359) and relationship filtering to interfaces. This would allow, for example, "outsourcing" the
EventRelations
to another entity:And then possibly construct a query like: