-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into stats_portal_improvements
- Loading branch information
Showing
30 changed files
with
1,039 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
class ActorConnectionType < BaseConnection | ||
edge_type(ActorEdgeType) | ||
field_class GraphQL::Cache::Field | ||
|
||
field :total_count, Integer, null: false, cache: true | ||
|
||
def total_count | ||
args = object.arguments | ||
|
||
Organization.query(args[:query], limit: 0).dig(:meta, "total").to_i + | ||
Funder.query(args[:query], limit: 0).dig(:meta, "total").to_i + | ||
Person.query(args[:query], limit: 0).dig(:meta, "total").to_i | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class ActorEdgeType < GraphQL::Types::Relay::BaseEdge | ||
node_type(ActorItem) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
module ActorItem | ||
include BaseInterface | ||
include Bolognese::MetadataUtils | ||
|
||
description "Information about people, research organizations and funders" | ||
|
||
field :id, ID, null: false, description: "The persistent identifier for the actor." | ||
field :type, String, null: false, description: "The type of the actor." | ||
field :name, String, null: false, description: "The name of the actor." | ||
field :alternate_name, [String], null: true, description: "An alias for the actor." | ||
|
||
definition_methods do | ||
# Determine what object type to use for `object` | ||
def resolve_type(object, context) | ||
if object.type == "Person" | ||
PersonType | ||
elsif object.type == "Organization" | ||
OrganizationType | ||
elsif object.type == "Funder" | ||
FunderType | ||
else | ||
raise "Unexpected Actor: #{object.inspect}" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.