Module: Graphiti::ActiveGraph::Scoping::Filter

Includes:
Extensions::QueryDsl::Performer, Filterable, Internal::SortingAliases
Defined in:
lib/graphiti/active_graph/scoping/filter.rb

Instance Attribute Summary collapse

Attributes included from Extensions::QueryDsl::Performer

#skip_arrow_cypher_rels, #with_vars

Instance Method Summary collapse

Methods included from Extensions::QueryDsl::Performer

#apply_query_dsl, #apply_query_param

Methods included from Internal::SortingAliases

#add_extra_vars_to_query?, #deep_sort_keys, #query, #sort_keys, #with_vars_for_sort

Methods included from Filterable

#find_filter!

Instance Attribute Details

#scopeObject (readonly)

Returns the value of attribute scope.



8
9
10
# File 'lib/graphiti/active_graph/scoping/filter.rb', line 8

def scope
  @scope
end

Instance Method Details

#applyObject



10
11
12
13
# File 'lib/graphiti/active_graph/scoping/filter.rb', line 10

def apply
  super
  apply_query_dsl
end

#each_filterObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/graphiti/active_graph/scoping/filter.rb', line 15

def each_filter
  filter_param.each_pair do |param_name, param_value|
    filter = find_filter!(param_name)

    normalize_param(filter, param_value).each do |operator, value|
      operator = operator.to_s.gsub("!", "not_").to_sym

      # dynamic filters errors for validating and typecasting value below
      # so they are skipped here without validation or typecast
      filter_map = filter.values[0]
      if filter_map[:dynamic_filter]
        yield filter, operator, value
        next
      end
      validate_operator(filter, operator)

      type = ::Graphiti::Types[filter_map[:type]]
      unless type[:canonical_name] == :hash || !value.is_a?(String)
        value = parse_string_value(filter_map, value)
      end

      check_deny_empty_filters!(resource, filter, value)
      value = parse_string_null(filter_map, value)
      validate_singular(resource, filter, value)
      value = coerce_types(filter_map, param_name.to_sym, value)
      validate_allowlist(resource, filter, value)
      validate_denylist(resource, filter, value)
      value = value[0] if filter_map[:single]
      yield filter, operator, value
    end
  end
end