feat(graphql): add code to timeout errors
This commit is contained in:
parent
f70532a844
commit
ae1ec87397
2 changed files with 13 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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' }
|
||||
|
|
Loading…
Reference in a new issue