Class: Decidim::Core::UserEntityFinder

Inherits:
Object
  • Object
show all
Defined in:
decidim-core/lib/decidim/api/functions/user_entity_finder.rb

Overview

A resolver for the GraphQL user/group endpoints Used in the keyword “user”, ie:

user(nickname: “foo”)

name

Instance Method Summary collapse

Instance Method Details

#call(_obj, args, ctx) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'decidim-core/lib/decidim/api/functions/user_entity_finder.rb', line 13

def call(_obj, args, ctx)
  filters = {
    organization: ctx[:current_organization]
  }
  args.each do |argument, value|
    next if value.blank?

    v = value.to_s
    v = v[1..-1] if value.starts_with? "@"
    filters[argument.to_sym] = v
  end
  Decidim::UserBaseEntity
    .confirmed
    .not_blocked
    .find_by(filters)
end