Skip to content

Commit

Permalink
Add user by unikey lookup to graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
johnf committed Nov 4, 2023
1 parent 1f08890 commit 7ae13c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/graphql/types/email_user_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module Types
class EmailUserType < Types::BaseObject
field :email, String

def self.authorized?(object, context)
super && context[:viewer].admin?
end
end
end
9 changes: 9 additions & 0 deletions app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,14 @@ def essence(full_identifier:, filename:)

item.essences.find_by(filename:)
end

field :user_by_uni_key, EmailUserType, 'Find a user by their unikey' do
argument :unikey, String
end

def user_by_uni_key(unikey:)
User.find_by(unikey:)
end

end
end

0 comments on commit 7ae13c9

Please sign in to comment.