3 ms·
And you can extend this pattern it by allowing "includes" which would signal to the backend to load and deliver the relations listed in the includes part of the
by saberdancer 6y ago
And you can extend this pattern it by allowing "includes" which would signal to the backend to load and deliver the relations listed in the includes part of the query.
This alone makes it impossible to get backend to return god entities with dozens of relations without explicitly specifying them.
- ldiracdelta 6y agoI accomplish this with the same `?fields` query param and it is fractal. You can specify which _fields_ of the relations below the User you also want. If `User` had `groups` and `groups` had `permissions`, then I can do: let results = await fetch('/rest/Users/?fields=' + JSON.stringify( { id: true, first_name: true, groups: { name: true, permissions: { name: true } } }); My system has its limitations however. It can't do relational constraints like GraphQL or renaming of fields, but it is likely the 20% that gets you 80% of the way.
- andrewingram 6y agoTo be honest, once you can traverse relationships like this, you've basically just got GraphQL in disguise and might as well be using it. You're going to have all the same difficulties as GraphQL in making it perform well, but don't have the elegant (IMO) query language -- and lose some of the expressivity of fields/relations being able to accept arguments.
- ldiracdelta 6y agoExcept I dont have to start with GraphQL. I can add the complexity when I need it instead of starting with complexity. Yes I finally got _one_ of the features of GraphQL, but I didn't have to swallow graphql or require everyone else to. They don't have to use the field specifier and it still looks very simple. In contrast to GraphQL.