Skip to content

Commit

Permalink
rudimentary support for querying current data_version
Browse files Browse the repository at this point in the history
  • Loading branch information
acoffman committed Feb 16, 2024
1 parent ead2448 commit 0402506
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/app/graphql/types/meta_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Types
class MetaType < Types::BaseObject
field :data_version, String, null: false

def data_version
DATA_VERSION
end
end
end
6 changes: 6 additions & 0 deletions server/app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class QueryType < Types::BaseObject
field :categories, resolver: Resolvers::Categories
field :interaction_claim_types, resolver: Resolvers::InteractionClaimTypes

field :dgidb_meta, Types::MetaType, null: false

field :drug_suggestions, [Types::DrugSuggestionType], null: true do
description "A searchable drug name or alias that can be completed from the supplied term"
argument :term, String, required: true
Expand Down Expand Up @@ -331,5 +333,9 @@ def interaction(id:)
def publication(id:)
Publication.find_by(id: id)
end

def dgidb_meta
{}
end
end
end
8 changes: 8 additions & 0 deletions server/config/initializers/dataset_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
file = File.join(Rails.root, 'data_version.yml')
data = YAML.load_file(file)

DATA_VERSION = data.dig('version')

if DATA_VERSION.nil?
raise StandardError.new("Missing or malformed data_version.yml. Expect file at Rails.root with a version: key")
end
1 change: 1 addition & 0 deletions server/data_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version: Dec-2023

0 comments on commit 0402506

Please sign in to comment.