Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Questions] Strategies on how to go for filtering relationships #60

Open
cecemel opened this issue Aug 15, 2019 · 3 comments
Open

[Questions] Strategies on how to go for filtering relationships #60

cecemel opened this issue Aug 15, 2019 · 3 comments

Comments

@cecemel
Copy link
Contributor

cecemel commented Aug 15, 2019

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.

@gr0uch
Copy link
Member

gr0uch commented Aug 16, 2019

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]=...

@gr0uch gr0uch closed this as completed Aug 16, 2019
@cecemel
Copy link
Contributor Author

cecemel commented Mar 23, 2020

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.

@gr0uch
Copy link
Member

gr0uch commented Mar 23, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants