Class: Decidim::Api::QueriesController
- Inherits:
-
ApplicationController
- Object
- DecidimController
- ApplicationController
- Decidim::Api::QueriesController
- Defined in:
- app/controllers/decidim/api/queries_controller.rb
Overview
This controller takes queries from an HTTP endpoint and sends them out to the Schema to be executed, later returning the response as JSON.
Instance Method Summary collapse
Methods inherited from ApplicationController
#permission_class_chain, #permission_scope
Instance Method Details
#create ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/decidim/api/queries_controller.rb', line 8 def create variables = prepare_variables(params[:variables]) query = params[:query] operation_name = params[:operationName] result = Schema.execute(query, variables:, context:, operation_name:) render json: result rescue StandardError => e logger.error e. logger.error e.backtrace.join("\n") = if Rails.env.development? { message: e., backtrace: e.backtrace } else { message: "Internal Server error" } end render json: { errors: [], data: {} }, status: :internal_server_error end |