Keeping in mind that the jsonapi spec clearly notes that it is agnostic about filtering strategies,
the recommended section provides some help regarding implementing search:
Furthermore, multiple filters can be applied to a single request:
GET /comments?filter[post]=1,2&filter[author]=12
What would be recommended way to filter on attributes of the relationships like author.name
?
Personally I don’t like all the square brackets so I would prefer something like filter[author.name]=John
,
but looking at the rest of the spec probably something like filter[author][name]=John
is closer.
In this forum I also saw examples like: filter[author:name]=John
.
What do you think is best, and would it be a good idea to document this in the recommended section?
Another I’m wondering is how to filter on nested relationships. Image the author has a nationality
relationship with a alpha2-code
attribute.
Filtering on this using dots could look like:
Using dots this could look like filter[author.nationality.alpha2-code]=NL
.
Using square brackets it could look like: filter[author][nationality][alpha2-code]=NL
.
What are your opinions?