projects/cloud/app/controllers/graphql_controller.rb
# 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
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
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
def execute
    if current_user.nil?
      url = "#{Rails.application.config.defaults[:urls][:app]}#{user_session_path}"
      error_message = "Authentication is required to interact with the GraphQL API. Authenticate through #{url}"
      error_extensions = { code: "AUTHENTICATION_ERROR" }
      raise GraphQL::ExecutionError.new(error_message, extensions: error_extensions)
    end
    variables = prepare_variables(params[:variables])
    query = params[:query]
    operation_name = params[:operationName]
    context = {
      current_user: current_user,
    }
    result = TuistCloudSchema.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
def execute if current_user . nil? url = "#{Rails.application.config.defaults[:urls][:app]}#{user_session_path}" error_message = "Authentication is required to interact with the GraphQL API. Authenticate through #{url}" error_extensions = { code : "AUTHENTICATION_ERROR" } raise GraphQL :: ExecutionError . new ( error_message , extensions : error_extensions ) end variables = prepare_variables ( params [ :variables ] ) query = params [ :query ] operation_name = params [ :operationName ] context = { current_user : current_user , } result = TuistCloudSchema . 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
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
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