-
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.
graphql connections for funders. #257
- Loading branch information
Martin Fenner
committed
May 12, 2019
1 parent
260db2a
commit 4f6d5d6
Showing
14 changed files
with
339 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class DatasetConnectionWithMetaType < GraphQL::Types::Relay::BaseConnection | ||
edge_type(EventEdgeType, edge_class: EventEdge) | ||
# edge_type(EventEdgeType) | ||
# field :total_count, Integer, null: false | ||
|
||
# def total_count | ||
# args = object.arguments | ||
|
||
# 1 | ||
# 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,23 @@ | ||
# frozen_string_literal: true | ||
|
||
class EventEdge < GraphQL::Relay::Edge | ||
def event | ||
logger = Logger.new(STDOUT) | ||
|
||
@event ||= begin | ||
Event.query(nil, subj_id: self.node[:id], obj_id: self.parent[:id])[:data].first | ||
end | ||
end | ||
|
||
def source | ||
event[:source_id].underscore.camelcase(:lower) | ||
end | ||
|
||
def relation_type | ||
event[:relation_type_id].underscore.camelcase(:lower) | ||
end | ||
|
||
def total | ||
event[:total] | ||
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,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class EventEdgeType < GraphQL::Types::Relay::BaseEdge | ||
node_type(DatasetType) | ||
|
||
field :source, String, null: false, description: "Source for this event" | ||
field :relation_type, String, null: false, description: "Relation type for this event" | ||
field :total, Integer, null: false, description: "Total count for this event" | ||
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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class FunderConnectionWithMetaType < GraphQL::Types::Relay::BaseConnection | ||
edge_type(FunderEdgeType) | ||
|
||
field :total_count, Integer, null: false | ||
|
||
def total_count | ||
args = object.arguments | ||
|
||
Funder.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 FunderEdgeType < GraphQL::Types::Relay::BaseEdge | ||
node_type(FunderType) | ||
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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