jsonapi.rb icon indicating copy to clipboard operation
jsonapi.rb copied to clipboard

Raise unless Ransack ignore_unknown_conditions?

Open sienic opened this issue 2 years ago • 3 comments

What is the current behavior?

https://github.com/stas/jsonapi.rb/issues/62

What is the new behavior?

It allows to use the Ransack configuration property ignore_unkown_conditions with the same semantics as in Ransack. A disadvantage of this solution is that Ransack so far has been a dependency of jsonapi.rb, and not necessarily of the projects which use Jsonapi.rb. Somehow it could be considered a co-dependency of jsonapi.rb, but that is not up to me.

Another solution would be to add a configuration object to jsonapi.rb.

Checklist

Please make sure the following requirements are complete:

  • [X] Tests for the changes have been added (for bug fixes / features)
  • [ ] Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • [ ] All automated checks pass (CI/CD)

sienic avatar Aug 25 '21 12:08 sienic

Unfortunately, this does not work with the sort parameter (which uses the same function I modified). I will wait for further feedback on how you'd like to go about this, as there are multiple possibilities, and this issue actually might not be an issue from your point of view.

sienic avatar Aug 25 '21 13:08 sienic

Thank you for this, @sienic. FWIW I decided to slightly slightly change your solution so that ActionController::BadRequest is raised instead of ArgumentError, resulting in a 400 response to the client instead of 500.

CofenseLabs-Doug avatar Apr 08 '22 18:04 CofenseLabs-Doug

@CofenseLabs-Doug 👍 @stas how about the other idea of having a way to configure jsonapi, so as to set properties for Ransack at https://github.com/stas/jsonapi.rb/blob/master/lib/jsonapi/patches.rb#L3-L6

sienic avatar Apr 09 '22 08:04 sienic