Permalink
Browse files

Added RANGE_ADD support for meetings mutation.

  • Loading branch information...
dblock committed Jul 9, 2018
1 parent f0bd7df commit 2a70b7ec7e7b2197d2b48156880ddaf3120d5ac3
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-07-07 22:33:50 -0400 using RuboCop version 0.57.2.
# on 2018-07-09 16:29:54 -0400 using RuboCop version 0.57.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
@@ -6,16 +6,30 @@
input_field :finished, !Types::DateTimeType

return_field :meeting, Types::MeetingType
return_field :meetingsConnection, Types::MeetingType.connection_type
return_field :meetingEdge, Types::MeetingType.edge_type

resolve ->(_object, inputs, ctx) {
if ctx[:current_user]
meeting = ctx[:current_user].meetings.create!(
user = ctx[:current_user]
if user
meeting = user.meetings.create!(
title: inputs[:title],
started_at: inputs[:started],
finished_at: inputs[:finished]
)

{ meeting: meeting }
range_add = GraphQL::Relay::RangeAdd.new(
parent: user,
collection: user.meetings,
item: meeting,
context: ctx
)

{
meeting: meeting,
meetingsConnection: range_add.connection,
meetingEdge: range_add.edge
}
else
GraphQL::ExecutionError.new('Not logged in.')
end
@@ -12,6 +12,11 @@
title
started
finished
},
meetingEdge {
node {
id
}
}
}
}
@@ -36,6 +41,9 @@
expect(DateTime.parse(meeting.started)).to eq started_at.utc.iso8601
expect(DateTime.parse(meeting.finished)).to eq finished_at.utc.iso8601

edge = response.data.create_meeting.meeting_edge
expect(edge.node.id).to eq meeting.id

user_meeting = current_user.meetings.first
expect(user_meeting).to_not be nil
expect(user_meeting.id.to_s).to eq meeting.id

0 comments on commit 2a70b7e

Please sign in to comment.