Commit 323f5146 authored by Luke Duncalfe's avatar Luke Duncalfe

Use GraphQL errors_on_object for collecting errors

Around 50% of our mutations were calling `object.errors.full_messages`
within their `#resolve` method, while others were using the
`#errors_on_object` helper in `BaseMutation`.

This MR changes all mutations to use `#errors_on_object`, and tweaks
the GraphQL API developer docs to mention the helper.
parent b94dac6a
......@@ -9,7 +9,7 @@ module Mutations
field :errors, [GraphQL::STRING_TYPE],
null: false,
description: "Errors encountered during execution of the mutation."
description: 'Errors encountered during execution of the mutation.'
def current_user
context[:current_user]
......
......@@ -19,7 +19,7 @@ module Mutations
{
issue: issue,
errors: issue.errors.full_messages
errors: errors_on_object(issue)
}
end
end
......
......@@ -19,7 +19,7 @@ module Mutations
{
issue: issue,
errors: issue.errors.full_messages
errors: errors_on_object(issue)
}
end
end
......
......@@ -33,7 +33,7 @@ module Mutations
{
issue: issue,
errors: issue.errors.full_messages
errors: errors_on_object(issue)
}
end
end
......
......@@ -40,7 +40,7 @@ module Mutations
{
merge_request: merge_request,
errors: merge_request.errors.full_messages
errors: errors_on_object(merge_request)
}
end
end
......
......@@ -41,7 +41,7 @@ module Mutations
{
merge_request: merge_request,
errors: merge_request.errors.full_messages
errors: errors_on_object(merge_request)
}
end
......
......@@ -21,7 +21,7 @@ module Mutations
{
merge_request: merge_request,
errors: merge_request.errors.full_messages
errors: errors_on_object(merge_request)
}
end
end
......
......@@ -22,7 +22,7 @@ module Mutations
{
merge_request: merge_request,
errors: merge_request.errors.full_messages
errors: errors_on_object(merge_request)
}
end
end
......
......@@ -18,7 +18,7 @@ module Mutations
{
merge_request: merge_request,
errors: merge_request.errors.full_messages
errors: errors_on_object(merge_request)
}
end
end
......
......@@ -21,7 +21,7 @@ module Mutations
{
merge_request: merge_request,
errors: merge_request.errors.full_messages
errors: errors_on_object(merge_request)
}
end
......
......@@ -690,8 +690,9 @@ should look like this:
# The merge request modified, this will be wrapped in the type
# defined on the field
merge_request: merge_request,
# An array if strings if the mutation failed after authorization
errors: merge_request.errors.full_messages
# An array of strings if the mutation failed after authorization.
# The `errors_on_object` helper collects `errors.full_messages`
errors: errors_on_object(merge_request)
}
```
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment