Class: Decidim::Core::UserEntityFinder

Inherits:
GraphQL::Function
  • Object
show all
Defined in:
app/functions/decidim/core/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



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/functions/decidim/core/user_entity_finder.rb', line 16

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
    .where.not(confirmed_at: nil)
    .find_by(filters)
end