Skip to content

Commit

Permalink
Merge pull request #204 from richmolj/master
Browse files Browse the repository at this point in the history
Ensure multiple filters work with legacy syntax
  • Loading branch information
richmolj authored Jan 31, 2020
2 parents 13998eb + 737e4b0 commit 0a4ab72
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
11 changes: 7 additions & 4 deletions lib/graphiti/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,13 @@ def filters
name = name.to_sym

if legacy_nested?(name)
filter_name = value.keys.first.to_sym
filter_value = value.values.first
if @resource.get_attr!(filter_name, :filterable, request: true)
hash[filter_name] = filter_value
value.keys.each do |key|
filter_name = key.to_sym
filter_value = value[key]

if @resource.get_attr!(filter_name, :filterable, request: true)
hash[filter_name] = filter_value
end
end
elsif nested?(name)
name = name.to_s.split(".").last.to_sym
Expand Down
2 changes: 1 addition & 1 deletion lib/graphiti/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Graphiti
VERSION = "1.2.14"
VERSION = "1.2.15"
end
11 changes: 11 additions & 0 deletions spec/query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,17 @@
expect(hash).to eq(expected)
end

context 'with multiple filters' do
before do
params[:filter][:positions][:id] = 4
end

it 'keeps both filters' do
expect(hash[:include][:positions][:filter])
.to eq(title: 'bar', id: 4)
end
end

context "with stringified keys" do
before do
params.deep_stringify_keys!
Expand Down

0 comments on commit 0a4ab72

Please sign in to comment.