5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/controllers/hasura_handler/actions_controller.rb', line 5
def process
unless HasuraHandler::Action.hasura_actions.keys.include?(action_params[:action][:name])
render json: { error: true, message: 'action name not registered' }, status: 404
return
end
klass = HasuraHandler::Action.hasura_actions[action_params[:action][:name]]
action = klass.new(action_params[:session_variables], action_params[:input])
action.run
if action.error_message.present?
render json: { error: true, message: action.error_message }, status: 400
else
render json: action.output
end
end
|