Class: GraphqlController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- GraphqlController
- Defined in:
- lib/graphql_controller.rb
Overview
bypasses card controller, executes graphql queries
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 22 23 24 |
# File 'lib/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 = GraphQL::CardSchema.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 |