-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Our GraphQL API grew very organically over the past years, basically only driven by our specific frontend needs. And that is fine, as the API is internal and we don't promise any stability. But maybe it's time to clean it up a bit, looking at it from an API design standpoint, not purely driven by the day-to-day requirement.
We are getting more and more questions about whether people can use the API, which we always have to decline. We already have a semi-stable part of the API. namely the part that is used by the Admin UI integration. We might want to properly stabilize parts of our API for everyone at some point and having a good API design is required for that. Further, a good design just makes it easier to work with it for our day to day tasks.
This issue is not something I expect we tackle very soon, but I wanted to have a place to collect ideas already.
Some random ideas I had:
-
Single endpoint to get some object with different parameters
- Currently we have
realmByIdandrealmByPath;eventByIdandeventByOpencastId, ... - Maybe we can replace all of them with
realm,event,seriesandplaylistendpoints - All these endpoints would have multiple optional parameters that allow the user to choose how to look up the item, e.g.
realm(id: ID, path: String). Then users can callrealm(id:"abc")orrealm(path:"/foo").- Sadly, the "only specify one of those arguments" cannot be enforced by the GraphQL type system as far as I can tell. But I don't think that would lead to any actual bugs in production, I would think this kind of error would immediately get noticed in development.
- For the Opencast items, we could also add a
hybrid: Stringparameter (name tbd) that accepts exactly our route syntax of<tobira-id>or:<oc_id>. That would drastically reduce some routing frontend code, getting rid of 6 route definitions. This seems a bit "adhoc" and driven by a very specific frontend need, but we cannot change route URLs anymore anyway, so that hybrid-ID syntax is now part of Tobira. So I don't think it's too bad to also put it into the API.
- Currently we have
-
Maybe improve return type of
eventandplaylist. It's currently a union eitherAuthorizedFooorNotAllowed. Andnullcan also be returned. This bothers me: theseriesendpoint is different; the main type for event/playlist is calledAuthorizedFoo; every query requires this annoying...on AuthorizedEvent { .. }level of indirection; we have to have this fake typeNotAllowedwith a dummy field.- We can of course just rename
AuthorizedFootoFooand theFootoFooResultor something else. - But can we maybe find another way of modelling this? So yes we have to model two special case: item not found and access not allowed.
- We can of course just rename
-
Adding consistency to the series/event "state" handling. We tried to avoid getting involved with sync-state stuff, but now it's too late and Tobira has to deal with it. Might as well have a consistent API for this.
-
Generally consistencies. Go through the whole API and see if there are any points where the same problem is solved in different ways.
-
...
(Ole feel free to just add ideas)