Skip to content

Update errors field description

Alex Kalderimis requested to merge ajk-mutation-errors into master

What does this MR do?

Addresses #216843 (closed)

We already have errors fields, so there is no reason to add any checks. The description is updated.

We could adapt this class to allow for custom error message types, but that would be a little funky as we would have to do something like the following:

class BaseMutations < Mutation
  def self.inherited(child_class)
    tp = TracePoint.new(:end) do |t|
      if child_class == t.self
        t.disable
        child_class.field :errors, [child_class.error_type],  null: false, description: child_class.error_description
      end
    end
    tp.enable
  end

  def self.error_type(type = GraphQL::STRING_TYPE)
    @error_type = type
  end

  def self.error_description(desc = 'Errors encountered during execution of the mutation')
    @description ||= desc
  end
end

class MuMutation < BaseMutation
  error_type MyCustomErrorType
end

That could be really handy for any class that wants to return anything richer than a string, but it total overkill right now.

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Alex Kalderimis

Merge request reports