diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 4646d67cf..9a68c01ed 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -4276,7 +4276,7 @@ type PublicationSoftwareConnectionWithMeta { type Query { _service: _Service! audiovisual(id: ID!): Audiovisual! - audiovisuals(first: Int = 25, query: String): [Audiovisual!]! + audiovisuals(first: Int = 25, hasCitations: Int, hasDownloads: Int, hasViews: Int, query: String): [Audiovisual!]! client(id: ID!): Client! clients( """ @@ -4388,10 +4388,11 @@ type Query { last: Int query: String ): FunderConnectionWithMeta! + heartbeat: String! image(id: ID!): Image! images(first: Int = 25, query: String): [Image!]! interactiveResource(id: ID!): InteractiveResource! - interactiveResources(first: Int = 25, query: String): [InteractiveResource!]! + interactiveResources(first: Int = 25, hasCitations: Int, hasDownloads: Int, hasViews: Int, query: String): [InteractiveResource!]! model(id: ID!): Model! models(first: Int = 25, query: String): [Model!]! organization(id: ID!): Organization! @@ -4435,7 +4436,7 @@ type Query { ): PersonConnectionWithMeta! person(id: ID!): Person physicalObject(id: ID!): PhysicalObject! - physicalObjects(first: Int = 25, query: String): [PhysicalObject!]! + physicalObjects(first: Int = 25, hasCitations: Int, hasDownloads: Int, hasViews: Int, query: String): [PhysicalObject!]! prefix(id: ID!): Prefix! prefixes(first: Int = 25, query: String): [Prefix!]! provider(id: ID!): Provider! diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb index 35c7b1d75..b56a40ca8 100644 --- a/app/graphql/types/query_type.rb +++ b/app/graphql/types/query_type.rb @@ -3,6 +3,14 @@ class QueryType < BaseObject extend_type + field :heartbeat, String, null: false do + end + + def heartbeat + heartbeat = Heartbeat.new + heartbeat.string + end + field :providers, ProviderConnectionWithMetaType, null: false, connection: true, max_page_size: 1000 do argument :query, String, required: false argument :first, Int, required: false, default_value: 25 @@ -345,8 +353,8 @@ def model(id:) argument :first, Int, required: false, default_value: 25 end - def physical_objects(query: nil, has_citations: has_citations, has_views: has_views, has_downloads: has_downloads, first: nil) - Doi.query(query, resource_type_id: "PhysicalObject", state: "findable", has_citations: nil, has_views: nil, has_downloads: nil, page: { number: 1, size: first }).results.to_a + def physical_objects(query: nil, has_citations: nil, has_views: nil, has_downloads: nil, first: nil) + Doi.query(query, resource_type_id: "PhysicalObject", state: "findable", has_citations: has_citations, has_views: has_views, has_downloads: has_downloads, page: { number: 1, size: first }).results.to_a end field :physical_object, PhysicalObjectType, null: false do diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb index 8cb816baf..e35e6ab53 100644 --- a/spec/graphql/types/query_type_spec.rb +++ b/spec/graphql/types/query_type_spec.rb @@ -126,4 +126,18 @@ expect(response.dig("data", "datasets", "nodes", 0, "references").first).to eq("id"=>"https://handle.test.datacite.org/#{target_doi.doi.downcase}", "publicationYear"=>2011) end end + + describe "heartbeat" do + let(:query) do + %(query { + heartbeat + }) + end + + it "returns the heartbeat" do + response = LupoSchema.execute(query).as_json + + expect(response.dig("data", "heartbeat")).to eq("OK") + end + end end