Skip to content

Commit

Permalink
query orcid api directly. #463
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Apr 8, 2020
1 parent 98b95ae commit 304c1b0
Show file tree
Hide file tree
Showing 10 changed files with 167 additions and 110 deletions.
20 changes: 20 additions & 0 deletions app/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ type Address {
type: String
}

"""
Information about affiliations
"""
type Affiliation {
"""
Unique identifier for each affiliation
"""
id: ID

"""
Affiliation name
"""
name: String
}

type Audiovisual implements DoiItem {
"""
The DOI registration agency for the resource
Expand Down Expand Up @@ -6380,6 +6395,11 @@ type PageInfo {
A person.
"""
type Person {
"""
Affiliations(s) of the person.
"""
affiliation: [Affiliation!]

"""
The number of citations.
"""
Expand Down
8 changes: 8 additions & 0 deletions app/graphql/types/affiliation_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

class AffiliationType < BaseObject
description "Information about affiliations"

field :id, ID, null: true, description: "Unique identifier for each affiliation"
field :name, String, null: true, description: "Affiliation name"
end
1 change: 1 addition & 0 deletions app/graphql/types/person_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class PersonType < BaseObject
field :name, String, null: true, description: "The name of the person."
field :given_name, String, null: true, description: "Given name. In the U.S., the first name of a Person."
field :family_name, String, null: true, description: "Family name. In the U.S., the last name of an Person."
field :affiliation, [AffiliationType], null: true, description: "Affiliations(s) of the person."
field :view_count, Integer, null: true, description: "The number of views according to the Counter Code of Practice."
field :download_count, Integer, null: true, description: "The number of downloads according to the Counter Code of Practice."
field :citation_count, Integer, null: true, description: "The number of citations."
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def person(id:)
end

def people(**args)
Person.query(args[:query], limit: args[:first]).fetch(:data, [])
Person.query(args[:query], rows: args[:first]).fetch(:data, [])
end

field :works, WorkConnectionType, null: false, connection: true, max_page_size: 1000 do
Expand Down
2 changes: 1 addition & 1 deletion app/models/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.find_by_id(id)
"given-names" => message.dig("name", "given-names", "value"),
"family-names" => message.dig("name", "family-name", "value"),
"other-name" => message.dig("name", "other-names", "other-name"),
"credit-name" => message.dig("name", "credit-name"),
"credit-name" => message.dig("name", "credit-name", "value"),
}

data = [parse_message(message: message)]
Expand Down
53 changes: 53 additions & 0 deletions spec/fixtures/vcr_cassettes/Person/find_by_id/also_found.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 304c1b0

Please sign in to comment.