hummingbird-me/kitsu-server

View on GitHub
app/graphql/mutations/pro/set_message.rb

Summary

Maintainability
A
20 mins
Test Coverage
F
50%
class Mutations::Pro::SetMessage < Mutations::Base
  argument :message, String,
    required: true,
    description: 'The message to set for your Hall of Fame entry'

  field :message, String, null: false

  def ready?
    # Check that we're logged in
    raise GraphQL::ExecutionError, ErrorI18n.t(NotLoggedInError) if user.blank?

    true
  end

  def resolve(message:)
    Pro::SetMessage.call(
      user: User.current,
      message: message
    )

    { message: message }
  rescue NotAuthorizedError => ex
    raise GraphQL::ExecutionError, ErrorI18n.t(ex)
  end
end