Class: Decidim::Api::QueriesController

Inherits:
ApplicationController show all
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

#createObject



8
9
10
11
12
13
# File 'app/controllers/decidim/api/queries_controller.rb', line 8

def create
  query_string = params[:query]
  query_variables = ensure_hash(params[:variables])
  result = Schema.execute(query_string, variables: query_variables, context: context)
  render json: result
end