Module: Rails::GraphQL::Controller

Extended by:
ActiveSupport::Concern
Defined in:
lib/rails/graphql/railties/controller.rb

Overview

GraphQL Controller

The controller helper methods that allow GraphQL to be performed on a Rails Controller class

Constant Summary collapse

REQUEST_XARGS =
%i[operation_name variables context schema query_cache_key].freeze
DESCRIBE_HEADER =
<<~TXT.freeze
  """
  Use the following HTTP params to modify this result:
    without_descriptions => Hide all descriptions
    without_spec => Hide all default spec types
  """
TXT

Instance Method Summary collapse

Instance Method Details

#describe(schema = gql_schema) ⇒ Object

GET /describe



36
37
38
39
40
41
42
# File 'lib/rails/graphql/railties/controller.rb', line 36

def describe(schema = gql_schema)
  render plain: [
    gql_schema_header(schema),
    gql_describe_schema(schema),
    gql_schema_footer,
  ].join
end

#executeObject

POST /execute



31
32
33
# File 'lib/rails/graphql/railties/controller.rb', line 31

def execute
  gql_request_response(gql_query)
end

#graphiqlObject

GET /graphiql



45
46
47
# File 'lib/rails/graphql/railties/controller.rb', line 45

def graphiql
  render '/graphiql', layout: false, locals: { settings: graphiql_settings }
end