Sha256: e14d2a51862a95864311345053fe62734689d1f376d159da56e3a81bd6ff7c7f

Contents?: true

Size: 833 Bytes

Versions: 9

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Core
    # A resolver for the GraphQL user/group endpoints
    # Used in the keyword "user", ie:
    #
    # user(nickname: "foo") {
    #   name
    # }
    #
    class UserEntityFinder < GraphQL::Function
      argument :id, types.ID, "The ID of the participant"
      argument :nickname, types.String, "The @nickname of the participant"

      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
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-core-0.23.6 app/functions/decidim/core/user_entity_finder.rb
decidim-core-0.23.5 app/functions/decidim/core/user_entity_finder.rb
decidim-core-0.23.4 app/functions/decidim/core/user_entity_finder.rb
decidim-core-0.23.3 app/functions/decidim/core/user_entity_finder.rb
decidim-core-0.23.2 app/functions/decidim/core/user_entity_finder.rb
decidim-core-0.23.1 app/functions/decidim/core/user_entity_finder.rb
decidim-core-0.23.1.rc1 app/functions/decidim/core/user_entity_finder.rb
decidim-core-0.23.0 app/functions/decidim/core/user_entity_finder.rb
decidim-core-0.22.0 app/functions/decidim/core/user_entity_finder.rb