feat(graphql): global not found error handling
This commit is contained in:
parent
fbae6d941d
commit
f70532a844
3 changed files with 41 additions and 9 deletions
|
@ -25,8 +25,6 @@ class API::V2::Schema < GraphQL::Schema
|
|||
|
||||
def self.object_from_id(id, ctx)
|
||||
ApplicationRecord.record_from_typed_id(id)
|
||||
rescue => e
|
||||
raise GraphQL::ExecutionError.new(e.message, extensions: { code: :not_found })
|
||||
end
|
||||
|
||||
def self.resolve_type(type_definition, object, ctx)
|
||||
|
@ -129,6 +127,10 @@ class API::V2::Schema < GraphQL::Schema
|
|||
super
|
||||
end
|
||||
|
||||
rescue_from(ActiveRecord::RecordNotFound) do |_error, _object, _args, _ctx, field|
|
||||
raise GraphQL::ExecutionError.new("#{field.type.unwrap.graphql_name} not found", extensions: { code: :not_found })
|
||||
end
|
||||
|
||||
class Timeout < GraphQL::Schema::Timeout
|
||||
def handle_timeout(error, query)
|
||||
Sentry.capture_exception(error, extra: query.context.query_info)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue