Skip to content

Commit d07c465

Browse files
authored
Merge pull request #482 from dgidb/dataset-version
Add support for GA4GH service info query
2 parents ab25888 + e9b8604 commit d07c465

File tree

8 files changed

+142
-10
lines changed

8 files changed

+142
-10
lines changed

client/src/pages/About/SubSections/Contact.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ export const Contact = () => {
66
<div className="contact-section-container doc-section">
77
<div>
88
<p>
9-
DGIdb was developed at The McDonnell Genome Institute, Washington
10-
University School of Medicine. If you have a source of information
11-
related to the druggable genome you would like us to incorporate,
12-
please contact us at{' '}
9+
DGIdb was initially developed at The McDonnell Genome Institute,
10+
Washington University School of Medicine. If you have a source of
11+
information related to the druggable genome you would like us to
12+
incorporate, please contact us at{' '}
1313
<Link href="mailto:[email protected]">[email protected].</Link>
1414
</p>
1515
<p>
@@ -24,12 +24,8 @@ export const Contact = () => {
2424

2525
<div className="left-section">
2626
<h4>
27-
<Link
28-
href="http://genome.wustl.edu/"
29-
target="_blank"
30-
rel="noreferrer"
31-
>
32-
The McDonnell Genome Institute
27+
<Link href="https://griffithlab.org" target="_blank" rel="noreferrer">
28+
The Griffith Laboratory
3329
</Link>
3430
</h4>
3531
<p>Washington University</p>

server/app/graphql/types/meta_type.rb

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
module Types
2+
class MetaType < Types::BaseObject
3+
field :id, String, null: false, description: 'Unique identifier for service.'
4+
field :data_version, String, null: false, description: 'Version of the data being served by DGIdb'
5+
field :name, String, null: false, description: 'Human readable name of the service'
6+
field :type, Types::ServiceType, null: false
7+
field :description, String, null: false
8+
field :organization, Types::OrganizationType, null: false
9+
field :contact_url, String, null: false, description: 'URL of the contact for the provider of this service'
10+
field :documentation_url, String, null: false, description: 'URL of the documentation of this service'
11+
field :created_at, GraphQL::Types::ISO8601DateTime, null: false, description: 'Timestamp describing when the service was first deployed and available'
12+
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false, description: 'Timestamp describing when the service was last updated'
13+
field :environment, String, null: false, description: 'Environment the service is running in'
14+
field :version, String, null: false, description: 'Version of the service being described'
15+
16+
def id
17+
'org.dgidb.graphql'
18+
end
19+
20+
def data_version
21+
DATA_VERSION
22+
end
23+
24+
def name
25+
'DGIdb'
26+
end
27+
28+
def type
29+
{}
30+
end
31+
32+
def description
33+
"An open-source search engine for drug-gene interactions and the druggable genome."
34+
end
35+
36+
def organization
37+
{}
38+
end
39+
40+
def contact_url
41+
42+
end
43+
44+
def documentation_url
45+
'https://dgidb.org/api/graphiql'
46+
end
47+
48+
def created_at
49+
#version 5.0.0 initial release on GitHub
50+
DateTime.parse("October 20, 2023 8:51 AM CDT")
51+
end
52+
53+
def updated_at
54+
DateTime.parse(github_release&.dig("published_at"))
55+
end
56+
57+
def environment
58+
Rails.env
59+
end
60+
61+
def version
62+
github_release&.dig("tag_name")
63+
end
64+
65+
private
66+
def github_release
67+
@rel ||= GithubRelease.current
68+
end
69+
end
70+
end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module Types
2+
class OrganizationType < Types::BaseObject
3+
field :name, String, null: false, description: 'Name of the organization responsible for the service'
4+
field :url, String, null: false, description: 'URL of the website of the organization'
5+
6+
def name
7+
'Wagner and Griffith laboratories'
8+
end
9+
10+
def url
11+
'https://dgidb.org/about#contact'
12+
end
13+
end
14+
end

server/app/graphql/types/query_type.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class QueryType < Types::BaseObject
1313
field :categories, resolver: Resolvers::Categories
1414
field :interaction_claim_types, resolver: Resolvers::InteractionClaimTypes
1515

16+
field :service_info, Types::MetaType, null: false
17+
1618
field :drug_suggestions, [Types::DrugSuggestionType], null: true do
1719
description "A searchable drug name or alias that can be completed from the supplied term"
1820
argument :term, String, required: true
@@ -331,5 +333,9 @@ def interaction(id:)
331333
def publication(id:)
332334
Publication.find_by(id: id)
333335
end
336+
337+
def service_info
338+
{}
339+
end
334340
end
335341
end
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module Types
2+
class ServiceType < Types::BaseObject
3+
field :group, String, null: false, description: 'Namespace in reverse domain name format.'
4+
field :artifact, String, null: false, description: 'Name of the API or GA4GH specification implemented.'
5+
field :version, String, null: false, description: 'API Version (semantic)'
6+
7+
def group
8+
'org.dgidb'
9+
end
10+
11+
def artifact
12+
'DGIdb GraphQL'
13+
end
14+
15+
def version
16+
GithubRelease.current&.dig("tag_name")
17+
end
18+
end
19+
end

server/app/models/github_release.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class GithubRelease
2+
def self.current
3+
Rails.cache.fetch("current_github_release", expires_in: 12.hours) do
4+
fetch_release
5+
end
6+
end
7+
8+
private
9+
def self.fetch_release
10+
uri = URI.parse('https://api.github.com/repos/dgidb/dgidb-v5/releases?per_page=1')
11+
resp = Net::HTTP.get_response(uri)
12+
if resp.code == '200'
13+
JSON.parse(resp.body).first
14+
else
15+
nil
16+
end
17+
end
18+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
file = File.join(Rails.root, 'data_version.yml')
2+
data = YAML.load_file(file)
3+
4+
DATA_VERSION = data.dig('version')
5+
6+
if DATA_VERSION.nil?
7+
raise StandardError.new("Missing or malformed data_version.yml. Expect file at Rails.root with a version: key")
8+
end

server/data_version.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version: Dec-2023

0 commit comments

Comments
 (0)