Merge pull request #8822 from tchak/graphql-error-handling

feat(graphql): log type and timeout errors
This commit is contained in:
Paul Chavard 2023-03-30 07:26:17 +00:00 committed by GitHub
commit 9e7e452c02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -121,7 +121,21 @@ class API::V2::Schema < GraphQL::Schema
raise GraphQL::ExecutionError.new("An object of type #{error.type.graphql_name} was hidden due to permissions", extensions: { code: :unauthorized }) raise GraphQL::ExecutionError.new("An object of type #{error.type.graphql_name} was hidden due to permissions", extensions: { code: :unauthorized })
end end
use GraphQL::Schema::Timeout, max_seconds: 10 def self.type_error(error, ctx)
# Capture type errors in Sentry. Thouse errors are our responsability and usually linked to
# instances of "bad data".
Sentry.capture_exception(error)
super
end
class Timeout < GraphQL::Schema::Timeout
def handle_timeout(error, query)
extra = { query: query.query_string, variables: query.provided_variables&.to_json }
Sentry.capture_exception(error, extra:)
end
end
use Timeout, max_seconds: 10
use GraphQL::Batch use GraphQL::Batch
use GraphQL::Backtrace use GraphQL::Backtrace