Class: Blog::GraphqlController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Blog::GraphqlController
- Defined in:
- app/controllers/blog/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.
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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/blog/graphql_controller.rb', line 8 def execute variables = prepare_variables(params[:variables]) query = params[:query] operation_name = params[:operationName] context = { # Query context goes here, for example: # current_user: current_user, } result = Schema.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 |