fortune-json-api
fortune-json-api copied to clipboard
[Questions] Strategies on how to go for filtering relationships
From issue #40 I learned filtering is not possible on relationships.
In the project I am working on, this would be a huge bonus to have it.
Do you have perhaps a strategy or vague idea, on how the library could be extend so I could filter e.g. like
?filter[shops.location.name]=somewhere
Thx.
Actually it is possible using fortune. It is just not part of the json api spec. Look for include query options.
Alternatively if you can afford making an additional request, you can apply any query on a relationship.
/users/1/relationships/friends?filter[fieldName]=...
Actually it is possible using fortune. It is just not part of the json api spec. Look for include query options.
Sorry, I am not completely following. I know it is not part of the spec, but if we want something like this, we need to extend fortune-json-api to support this? Right?
If so, it might be that we allocate some extra time to allow these and other filters. We deal with a lot of data, which need to be paginated. Once you start paginating, the need for advanced filtering is really prominent.
In that respect, it might be handy that these extensions remain compatible for future versions of this library too.
Would it be possible to give some high level pointers on how you would approach this, and perhaps give a hint on how you would see the api for filtering designed? I've seen min/max filters already and so I also think it is not wrong to implement your own flavour of filtering. An escape hatch foreseen by the spec. If we look at e.g. Ember.js, the filtering is completely unspecified and you can pretty much do what you want.
What do you think e.g about:
filter[resource.relation-1.relation-2.prop][filter-type]=value
and similar for sorting
sort[resource.relation-1.relation-2.prop]=direction
Thanks for the feedback.
oh yeah, using the filter option is the way to go here. I am just saying it isn't mandated nor specified, and I currently haven't implemented this in the json api serializer.
it really wouldn't take much effort since it's just passing options from the query parameter to the request method.