graphiti: Cannot make custom operators for `hash` type

You cannot make custom operators for a filter of hash type. They all get coerced to be eq. Looks like its happening on this line: https://github.com/graphiti-api/graphiti/blob/master/lib/graphiti/scoping/filter.rb#L83 https://github.com/graphiti-api/graphiti/blob/master/lib/graphiti/scoping/filter.rb#L131-L133

It may be this is code is trying to support the syntax of filter[metadata]={ "foo": 100 } instead of the regular filter[metadata][eq]={ "foo": 100 }

If that’s the case, perhaps the = character should be targeted and supported specifically instead of coercing all other potential operator types to be eq

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (15 by maintainers)

Most upvoted comments

Well, we’re not trying to build in any default behavior. We just want to make sure if the user defines a custom operator (could be match or could be foobar) that it is called:

filter :my_hash, :hash do
  match do |scope, value|
    puts 'I SHOULD BE CALLED!'
  end
end