thephpleague / fractal

Output complex, flexible, AJAX/RESTful data structures.
fractal.thephpleague.com
MIT License
3.52k stars 352 forks source link

Filters on relationships #522

Closed devexsolutions closed 2 years ago

devexsolutions commented 3 years ago

Hi, how can I apply filters on relationships?

GET /comments?filter[post]=1,2&filter[author]=12 HTTP/1.1

Thanks

alkhachatryan commented 3 years ago

The same question from me.

matthewtrask commented 3 years ago

Fractal is a serializer and data transformer, so it doesn't really look at what you are passing to the request. You would need to handle the filter in your own code and then conditionally handle the data being sent to your transformer.

willishq commented 3 years ago

I agree, however I think in the documentation there is a reference to the querystring being used to parse includes, which could cause some confusion.

Maybe we need to change the documentation to be explicit that Fractal does not choose what data you pass to it (such as posts with a specific ID or Author) and instead manages on how to display the data passed to it.

Interestingly, as an aside, I did try to solve this problem 3 years ago with a package I called query-grid, however the concept is pretty complex and it's probably easier to write things like filtering by hand per use-case rather than try to create a catch-all package.

matthewtrask commented 2 years ago

Im going to close this for now, but if this is still a persistent issue please feel free to reopen.