Class: GraphqlController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/potassium/assets/app/graphql/graphql_controller.rb

Instance Method Summary collapse

Instance Method Details

#executeObject

If accessing from outside this domain, nullify the session This allows for outside API access while preventing CSRF attacks, but you’ll have to authenticate your user separately protect_from_forgery with: :null_session



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/potassium/assets/app/graphql/graphql_controller.rb', line 7

def execute
  variables = prepare_variables(params[:variables])
  query = params[:query]
  operation_name = params[:operationName]
  context = { current_user: get_current_user }
  result = GqlSampleSchema.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