-
Notifications
You must be signed in to change notification settings - Fork 109
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
Filtering validator broken when query resource by id #218
Comments
Filtering on a specific resource's endpoint is not supported by this package, which is why you're getting the error. Instead the package allows filtering by id values on the index route, i.e. you can do any of the following:
At the moment though if the
I.e. give me posts 1 and 4, but only if they are published. I think this is equivalent to your scenario. I was going to do a release very soon (in the next few days), so I'll include this fix in it. |
Thanks for the quick response. Looks like the secondary issue I just reported: |
Have added this feature to the
Returns post 1 if it is published. The same is also now possible on to-one relations:
Returns the post that is associated to comment 1 if that post is published. |
Sort and page params are still not supported on these endpoints because there is no point sorting and paging a resource end-point that is going to return a specific resource or |
Filtering validator does not read filter values when requesting resource by id.
Can be replicated using the demo-laravel-json-api.
by ID
http://demo-laravel-json-api.homestead/api/v1/posts/15?filter[title]=Voluptas perspiciatis
by index filter is recognized works as expected
http://demo-laravel-json-api.homestead/api/v1/posts?filter[title]=Voluptas perspiciatis
I want to filter by related model. For the sake of using demo-laravel-json-api, I'm just using the existing user model relation for proof of concept. But you can imagine appropriate scenario for filtering a has-many relationship.
Working example:
http://demo-laravel-json-api.homestead/api/v1/posts?include=author&filter[user.name]=Fabian
Using a custom filter:
Works as expected.
-Returns all posts and includes only user (author) record for Fabian.
Issue is querying by record ID, filters aren't recognized. Filters are valid as established in previous examples.
http://demo-laravel-json-api.homestead/api/v1/posts/15?include=author&filter[user.name]=Fabian
How to implement filtering when fetching record by ID?
The text was updated successfully, but these errors were encountered: