From 775a677465c6ae56fccc2d8647257c3efb92c5eb Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 30 Sep 2020 11:59:49 +0200 Subject: [PATCH] GraphQL handle parse errors --- app/controllers/api/v2/graphql_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/api/v2/graphql_controller.rb b/app/controllers/api/v2/graphql_controller.rb index 2e2f783bd..f25bf041d 100644 --- a/app/controllers/api/v2/graphql_controller.rb +++ b/app/controllers/api/v2/graphql_controller.rb @@ -18,6 +18,12 @@ class API::V2::GraphqlController < API::V2::BaseController private + def process_action(*args) + super + rescue ActionDispatch::Http::Parameters::ParseError => exception + render status: 400, json: { errors: [{ message: exception.cause.message }] } + end + # Handle form data, JSON body, or a blank value def ensure_hash(ambiguous_param) case ambiguous_param