diff --git a/app/controllers/api/v2/graphql_controller.rb b/app/controllers/api/v2/graphql_controller.rb index 1bebb48e7..4e9802b3a 100644 --- a/app/controllers/api/v2/graphql_controller.rb +++ b/app/controllers/api/v2/graphql_controller.rb @@ -8,6 +8,8 @@ class API::V2::GraphqlController < API::V2::BaseController operation_name: params[:operationName]) render json: result + rescue GraphQL::ParseError => exception + handle_parse_error(exception) rescue => exception if Rails.env.production? handle_error_in_production(exception) @@ -88,6 +90,15 @@ class API::V2::GraphqlController < API::V2::BaseController end end + def handle_parse_error(exception) + render json: { + errors: [ + { message: exception.message } + ], + data: nil + }, status: 400 + end + def handle_error_in_development(exception) logger.error exception.message logger.error exception.backtrace.join("\n")