Skip to content

Commit

Permalink
properly show researcher affiliations in graphql. #318
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jul 21, 2019
1 parent 3c394b8 commit dd37c03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/graphql/types/organization_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ class OrganizationType < BaseObject
argument :first, Int, required: false, default_value: 25
end

def id
object.id || object.fetch("affiliationIdentifier", nil)
end

def name
object.name || object.fetch("name", nil)
end

def datasets(**args)
ids = Event.query(nil, obj_id: object[:id], citation_type: "Dataset-Organization").results.to_a.map do |e|
doi_from_url(e.subj_id)
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/researcher_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ResearcherType < BaseObject
field :name_type, String, null: true, hash_key: "nameType", description: "The type of name"
field :given_name, String, null: true, hash_key: "givenName", description: "Researcher given name"
field :family_name, String, null: true, hash_key: "familyName", description: "Researcher family name"
field :affiliation, [String], null: true, description: "Researcher affiliation"
field :affiliation, [OrganizationType], null: true, description: "Researcher affiliation"
field :datasets, ResearcherDatasetConnectionWithMetaType, null: true, description: "Authored datasets", connection: true, max_page_size: 100 do
argument :first, Int, required: false, default_value: 25
end
Expand Down

0 comments on commit dd37c03

Please sign in to comment.