caprese icon indicating copy to clipboard operation
caprese copied to clipboard

Add Support for Multiple Values in Filter

Open drush opened this issue 7 years ago • 2 comments

JSONAPI implementations may support multiple values for a filter to reduce the number of queries on the server side: http://jsonapi.org/recommendations/#filtering

GET /comments?filter[post_id]=1,2 HTTP/1.1

The resulting query should be an IN query in rails:

Comment.where(post_id: values).to_sql 
=> SELECT * FROM comments where post_id IN(val1, va2)

drush avatar Dec 15 '17 00:12 drush

SUPPORTED: GET /comments?filter[attr][]=1&filter[attr][]=2 HTTP/1.1

NOT SUPPORTED: GET /comments?filter[attr][0]=1&filter[attr][1]=2 HTTP/1.1 GET /comments?filter[post_id]=1,2 HTTP/1.1

drush avatar Dec 20 '17 01:12 drush

Gonna leave this open because though I like the solution, I want to continually improve JSON API adherence

nicklandgrebe avatar Dec 22 '17 17:12 nicklandgrebe