data_importer/lib/github_api/user.rb

29 lines
No EOL
701 B
Ruby

require '/data_importer/lib/github_api/github_api.rb'
module GithubApi
class User
UserProfileQuery = GithubApi::Client.parse <<-'GRAPHQL'
query($username: String!) {
user(login: $username) {
id
login
name
avatarUrl
bio
bioHTML
location
}
}
GRAPHQL
def self.find(username)
response = GithubApi::Client.query(UserProfileQuery, variables: { username: username })
if response.errors.any?
raise QueryExecutionError.new(response.errors[:data].join(", "))
else
response.data.user
end
end
end
end
class QueryExecutionError < StandardError; end