lib/generators/graphql/templates/graphql_controller.erb in graphql-1.8.4 vs lib/generators/graphql/templates/graphql_controller.erb in graphql-1.8.5

- old
+ new

@@ -7,10 +7,13 @@ # Query context goes here, for example: # current_user: current_user, } result = <%= schema_name %>.execute(query, variables: variables, context: context, operation_name: operation_name) render json: result + rescue => e + raise e unless Rails.env.development? + handle_error_in_development e end private # Handle form data, JSON body, or a blank value @@ -27,7 +30,14 @@ when nil {} else raise ArgumentError, "Unexpected parameter: #{ambiguous_param}" end + end + + def handle_error_in_development(e) + logger.error e.message + logger.error e.backtrace.join("\n") + + render json: { error: { message: e.message, backtrace: e.backtrace }, data: {} }, status: 500 end end