From 69114abe9faa22408b262d56f1a95c5040748571 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Thu, 23 Apr 2020 18:06:59 +0200 Subject: [PATCH] support doi in graphql fields --- app/graphql/schema.graphql | 130 ++++++++++++++++++++++++ app/graphql/types/doi_item.rb | 1 + spec/graphql/types/service_type_spec.rb | 2 + 3 files changed, 133 insertions(+) diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 07dade305..02547bed6 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -116,6 +116,11 @@ type Audiovisual implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -556,6 +561,11 @@ type Book implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -955,6 +965,11 @@ type BookChapter implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -1436,6 +1451,11 @@ type Collection implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -1875,6 +1895,11 @@ type ConferencePaper implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -2539,6 +2564,11 @@ type DataPaper implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -2979,6 +3009,11 @@ type Dataset implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -3529,6 +3564,11 @@ type Dissertation implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -3972,6 +4012,11 @@ interface DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -4371,6 +4416,11 @@ type Event implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -4796,6 +4846,11 @@ type EventData implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -5545,6 +5600,11 @@ type Image implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -5985,6 +6045,11 @@ type Instrument implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -6425,6 +6490,11 @@ type InteractiveResource implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -6885,6 +6955,11 @@ type JournalArticle implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -7700,6 +7775,11 @@ type Model implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -8360,6 +8440,11 @@ type Other implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -8825,6 +8910,11 @@ type PeerReview implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -9491,6 +9581,11 @@ type PhysicalObject implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -9984,6 +10079,11 @@ type Preprint implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -10424,6 +10524,11 @@ type Publication implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -12238,6 +12343,11 @@ type Service implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -12678,6 +12788,11 @@ type Software implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -13149,6 +13264,11 @@ type Sound implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -13772,6 +13892,11 @@ type Work implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ @@ -14213,6 +14338,11 @@ type Workflow implements DoiItem { """ descriptions(first: Int = 5): [Description!] + """ + The DOI for the resource. + """ + doi: String! + """ Total number of downloads """ diff --git a/app/graphql/types/doi_item.rb b/app/graphql/types/doi_item.rb index 50f7ba14f..f67f7d5b3 100644 --- a/app/graphql/types/doi_item.rb +++ b/app/graphql/types/doi_item.rb @@ -8,6 +8,7 @@ module DoiItem field :id, ID, null: false, hash_key: "identifier", description: "The persistent identifier for the resource" field :type, String, null: false, description: "The type of the item." + field :doi, String, null: false, description: "The DOI for the resource." field :creators, [CreatorType], null: true, description: "The main researchers involved in producing the data, or the authors of the publication, in priority order" do argument :first, Int, required: false, default_value: 20 end diff --git a/spec/graphql/types/service_type_spec.rb b/spec/graphql/types/service_type_spec.rb index 88f64328d..61d537f2b 100644 --- a/spec/graphql/types/service_type_spec.rb +++ b/spec/graphql/types/service_type_spec.rb @@ -32,6 +32,7 @@ } nodes { id + doi identifiers { identifier identifierType @@ -60,6 +61,7 @@ service = response.dig("data", "services", "nodes", 0) expect(service.fetch("id")).to eq(services.first.identifier) + expect(service.fetch("doi")).to eq(services.first.doi) expect(service.fetch("identifiers")).to eq([{"identifier"=> "Ollomo B, Durand P, Prugnolle F, Douzery EJP, Arnathau C, Nkoghe D, Leroy E, Renaud F (2009) A new malaria agent in African hominids. PLoS Pathogens 5(5): e1000446.", "identifierType"=>nil}])