Commit f10295b2 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'ajk-handle-gql-errors' into 'master'

Propagate argument errors as execution errors

See merge request gitlab-org/gitlab-ce!31249
parents cbceb1ce 8a1fc36e
......@@ -30,6 +30,10 @@ class GraphqlController < ApplicationController
render_error(exception.message, status: :unprocessable_entity)
end
rescue_from Gitlab::Graphql::Errors::ArgumentError do |exception|
render_error(exception.message, status: :unprocessable_entity)
end
private
def execute_multiplex
......
......@@ -7,6 +7,27 @@ describe GraphqlController do
stub_feature_flags(graphql: true)
end
describe 'ArgumentError' do
let(:user) { create(:user) }
let(:message) { 'green ideas sleep furiously' }
before do
sign_in(user)
end
it 'handles argument errors' do
allow(subject).to receive(:execute) do
raise Gitlab::Graphql::Errors::ArgumentError, message
end
post :execute
expect(json_response).to include(
'errors' => include(a_hash_including('message' => message))
)
end
end
describe 'POST #execute' do
context 'when user is logged in' do
let(:user) { create(:user) }
......
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