Skip to content

Instantly share code, notes, and snippets.

@hash32bot
Last active December 25, 2018 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hash32bot/bbd8f6a5de3c5bbed163882c0242811b to your computer and use it in GitHub Desktop.
Save hash32bot/bbd8f6a5de3c5bbed163882c0242811b to your computer and use it in GitHub Desktop.
Speaker Mutations - resolve - [Post] GraphQL with Sinatra (Ruby) - Part 2- Mutations
require 'graphql'
require_relative 'base_mutation'
class Mutations::CreateSpeaker < Mutations::BaseMutation
description 'Creates a speaker'
# input arguments
def resolve(name:, bio:, twitter_handle:, talk_title:)
speaker = Speaker.new(
name: name,
bio: bio,
twitter_handle: twitter_handle,
talk_title: talk_title
)
if speaker.save
{
success: true,
errors: []
}
else
{
success: false,
errors: speaker.errors.full_messages
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment