Skip to content

Commit

Permalink
address fields differently
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Oct 11, 2019
1 parent 6bb5520 commit 0c1fdc0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions app/graphql/types/event_data_edge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ class EventDataEdge < GraphQL::Relay::Edge

def event_data
@event_data ||= begin
Event.query(nil, subj_id: self.node[:id], obj_id: self.parent[:id]).results.first.to_h
Event.query(nil, subj_id: self.node.id, obj_id: self.parent.id).results.first.to_h
end
end

def source_id
self.node[:id]
self.node.id
end

def target_id
self.parent[:id]
self.parent.id
end

def source
event_data[:source_id].underscore.camelcase(:lower)
event_data.source_id.underscore.camelcase(:lower)
end

# We are switching subj and obj, and thus need to change direction of relation type
def relation_type
rt = event_data[:relation_type_id].underscore.camelcase(:lower)
rt = event_data.relation_type_id.underscore.camelcase(:lower)
RELATION_TYPES.fetch(rt, rt)
end

def total
event_data[:total]
event_data.total
end
end
10 changes: 5 additions & 5 deletions app/graphql/types/event_data_edge_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
class EventDataEdgeType < GraphQL::Types::Relay::BaseEdge
node_type(EventDataType)

field :source_id, String, null: false, description: "The source ID of the event."
field :target_id, String, null: false, description: "The target ID of the event."
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."
field :source_id, String, null: true, description: "The source ID of the event."
field :target_id, String, null: true, description: "The target ID of the event."
field :source, String, null: true, description: "Source for this event"
field :relation_type, String, null: true, description: "Relation type for this event."
field :total, Integer, null: true, description: "Total count for this event."
end

0 comments on commit 0c1fdc0

Please sign in to comment.