Declarative strict ordering on links via GraphQL

Thanks Anthony,

I see this has already been discussed. My mistake for not finding any of those sooner…

I’d imagine that for 90% of use-cases, the Set-like behavior of Lists would work absolutely fine. However, the power of GraphQL comes from the brevity of the APIs that utilize it. If I may address the workarounds mentioned in this topic and others.

Doing this requires an additional query to find all current scores. For a list of size n, inserting at position i may require n-i mutations (in the case where the pre-insertion orders respectively are [1,2,3,4, … , n-1, n]). This places the generated GraphQL API into a performance pitfall similar to the N+1 Problem; a problem GraphQL aims to solve

This is actually a pretty fair idea. Unfortunately this doesn’t work well for storing lists of complex structures, such as large JSON-like objects. At best, we’ll end up overfetching everything in the list, and at worst, the objects will refer to the IDs of other types, leading to additional queries. Again, the very issues GraphQL aims to solve in the first place.

Just to be clear, I understand the reasoning behind the current behavior, and the performance implications of changing said behavior. Personally (and I believe others will share this opinion), I think an “@orderable” directive on lists is a reasonable feature. Under the hood, it could use an “order” value that isn’t seen in the generated API. Another point made in other topics is that the GraphQL spec doesn’t say that the lists should be orderable, just they are ordered. So yes, Dgraph lists are to spec in that sense, but for the reasons outlined above I believe it’s against the spirit of GraphQL for Dgraph to be missing such an option.

1 Like