sort many_to_many
I thought I had asked this question before, but can't seem to find it...
It seems like a very common use case, but not sure how to go about this.
Is it possible to sort a many_to_many relationship based on a field in the join table.
ie. if I have a Playlist:
and an Item:
And a PlaylistEntry:
And I want to simply load this in graphql by just adding the items:
I know that in graphql not all values that are not needed in the read are selected, but apart from graphQL is there a way to get this sorting happening.
Thanks all!
5 Replies
You can sort the relationship in the DSL declaration, i.e
sort :foo
Would that suffice?I guess that should suffice, but where should I put it? in the many_to_many?
What you'd need to do is something like this:
Alternatively, if you expose the join relationship then the client can use that to sort
i.e
ok, cool. How does one expose a relationship?
If you split it out as shown, and give the join resource a graphql tyoe, that should do it