You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Array of strings filters raise an error when only one value is supplied #370
This might be of some help to you. We've run into a similar issue and weren't sure if it was our old version of Graphiti (1.3.5) or not so we've not reported it as a bug yet.
In our controller that accepts a filter similar to how you describe, we do this:
defindexifparams[:filter][:excluded_food_groups].class != ActionController::Parameters# The user dictated a filter matching style of "case-insensitive equality (:eq)" which Graphiti has already# unwrapped from the parameters, or they did not dictate any filter matching style at# all (not :gt, nor :gte, etc.) which means we can safely assume they wanted a matching style of "case-insensitive# equality (:eq)", so proceed with guaranteeing the excluded_food_groups parameter is an array.# Guarantee that if a single excluded food group is given that it is placed into an array to make our desired# Graphiti attribute type (:array_of_strings) happy. Multiple excluded food groups don't need to be turned into an array# this way, but it doesn't hurt. Hopefully Graphiti 2.0 fixes this issue so we no longer need this work-around.# TODO: When that time comes, remove the conditional above and this line of code. Runs tests and assess the# situation.params[:filter][:excluded_food_groups]=params[:filter][:excluded_food_groups].split(',').flattenendrecommendations=RecommendationResource.all(params)respond_todo |format|
format.json{render(json: recommendations)}format.jsonapi{render(jsonapi: recommendations)}format.xml{render(xml: pretty_xml(recommendations))}endend
(Ignore the pretty_xml part. That's our work-around to a different Graphiti bug.)
Hi. I faced the same problem. I would prefer not to update parameters in the controller because it doesn't fix the same issue during sideloading so I just redefined the filter using string value type and then explicitly split it:
filter :label_ids, :string, only: [:intersects] do
intersects do |scope, label_ids|
scope.joins(:item_labels).where(item_labels: { label_id: label_ids.split(',') }).distinct
end
end
Activity
Ben-Fenner commentedon May 23, 2022
This might be of some help to you. We've run into a similar issue and weren't sure if it was our old version of Graphiti (1.3.5) or not so we've not reported it as a bug yet.
In our controller that accepts a filter similar to how you describe, we do this:
(Ignore the
pretty_xmlpart. That's our work-around to a different Graphiti bug.)bguban commentedon Nov 1, 2024
Hi. I faced the same problem. I would prefer not to update parameters in the controller because it doesn't fix the same issue during sideloading so I just redefined the filter using
stringvalue type and then explicitly split it:github-actions commentedon Aug 2, 2026
🎉 This issue has been resolved in version 1.13.1 🎉
The release is available on:
v1.13.1Your semantic-release bot 📦🚀
github-actions commentedon Aug 10, 2026
🎉 This issue has been resolved in version 2.0.0-beta.8 🎉
The release is available on:
v2.0.0-beta.8Your semantic-release bot 📦🚀