gitlab-org--gitlab-foss/app/graphql/mutations/base_mutation.rb
Luke Duncalfe 67030789f5 Include AuthorizeResource module for all mutations
This makes our authorization calls available to all GraphQL mutations
without the additional step of including the module first.
2019-07-11 15:08:34 +12:00

21 lines
543 B
Ruby

# frozen_string_literal: true
module Mutations
class BaseMutation < GraphQL::Schema::RelayClassicMutation
prepend Gitlab::Graphql::Authorize::AuthorizeResource
prepend Gitlab::Graphql::CopyFieldDescription
field :errors, [GraphQL::STRING_TYPE],
null: false,
description: "Reasons why the mutation failed."
def current_user
context[:current_user]
end
# Returns Array of errors on an ActiveRecord object
def errors_on_object(record)
record.errors.full_messages
end
end
end