Skip to content

Commit

Permalink
support doi in graphql fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Apr 23, 2020
1 parent 7a70d92 commit 69114ab
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 0 deletions.
130 changes: 130 additions & 0 deletions app/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ type Audiovisual implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -556,6 +561,11 @@ type Book implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -955,6 +965,11 @@ type BookChapter implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -1436,6 +1451,11 @@ type Collection implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -1875,6 +1895,11 @@ type ConferencePaper implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -2539,6 +2564,11 @@ type DataPaper implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -2979,6 +3009,11 @@ type Dataset implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -3529,6 +3564,11 @@ type Dissertation implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -3972,6 +4012,11 @@ interface DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -4371,6 +4416,11 @@ type Event implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -4796,6 +4846,11 @@ type EventData implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -5545,6 +5600,11 @@ type Image implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -5985,6 +6045,11 @@ type Instrument implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -6425,6 +6490,11 @@ type InteractiveResource implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -6885,6 +6955,11 @@ type JournalArticle implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -7700,6 +7775,11 @@ type Model implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -8360,6 +8440,11 @@ type Other implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -8825,6 +8910,11 @@ type PeerReview implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -9491,6 +9581,11 @@ type PhysicalObject implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -9984,6 +10079,11 @@ type Preprint implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -10424,6 +10524,11 @@ type Publication implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -12238,6 +12343,11 @@ type Service implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -12678,6 +12788,11 @@ type Software implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -13149,6 +13264,11 @@ type Sound implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -13772,6 +13892,11 @@ type Work implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down Expand Up @@ -14213,6 +14338,11 @@ type Workflow implements DoiItem {
"""
descriptions(first: Int = 5): [Description!]

"""
The DOI for the resource.
"""
doi: String!

"""
Total number of downloads
"""
Expand Down
1 change: 1 addition & 0 deletions app/graphql/types/doi_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/graphql/types/service_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
}
nodes {
id
doi
identifiers {
identifier
identifierType
Expand Down Expand Up @@ -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}])
Expand Down

0 comments on commit 69114ab

Please sign in to comment.