feat(graphql): add code to timeout errors

This commit is contained in:
Paul Chavard 2023-04-18 10:27:20 +02:00
parent f70532a844
commit ae1ec87397
2 changed files with 13 additions and 0 deletions

View file

@ -133,6 +133,7 @@ class API::V2::Schema < GraphQL::Schema
class Timeout < GraphQL::Schema::Timeout
def handle_timeout(error, query)
error.extensions = { code: :timeout }
Sentry.capture_exception(error, extra: query.context.query_info)
end
end

View file

@ -64,6 +64,18 @@ describe API::V2::GraphqlController do
}
end
context 'timeout' do
let(:variables) { { dossierNumber: dossier.id } }
let(:operation_name) { 'getDossier' }
before { allow_any_instance_of(API::V2::Schema::Timeout).to receive(:max_seconds).and_return(0) }
it {
expect(gql_errors.first[:message]).to eq('Timeout on Query.dossier')
expect(gql_errors.first[:extensions]).to eq({ code: 'timeout' })
}
end
context 'getDossier' do
let(:variables) { { dossierNumber: dossier.id } }
let(:operation_name) { 'getDossier' }