Sha256: 2cffca8b7611a3c3b06e3d7292bcf6c9b69e83895552fb3a181e8e2a005c9d91
Contents?: true
Size: 944 Bytes
Versions: 5
Compression:
Stored size: 944 Bytes
Contents
module DateBook class GraphqlController < DateBookController def execute variables = ensure_hash(params[:variables]) query = params[:query] operation_name = params[:operationName] context = { # Query context goes here, for example: current_user: current_user, } result = DateBookSchema.execute(query, variables: variables, context: context, operation_name: operation_name) render json: result end private # Handle form data, JSON body, or a blank value def ensure_hash(ambiguous_param) case ambiguous_param when String if ambiguous_param.present? ensure_hash(JSON.parse(ambiguous_param)) else {} end when Hash, ActionController::Parameters ambiguous_param when nil {} else raise ArgumentError, "Unexpected parameter: #{ambiguous_param}" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems