Class: GraphqlController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- GraphqlController
- Defined in:
- app/controllers/graphql_controller.rb
Instance Method Summary collapse
-
#execute ⇒ Object
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.
Methods included from Response
Instance Method Details
#execute ⇒ Object
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
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/graphql_controller.rb', line 10 def execute variables = ensure_hash(params[:variables]) query = params[:query] operation_name = params[:operationName] context = { current_user: current_user } result = BackendSchema.execute(query, variables: variables, context: context, operation_name: operation_name) render json: result rescue StandardError => e raise e unless Rails.env.development? handle_error_in_development e end |