Table of Contents
This gem provides the
GraphQL::Controller concern that has everything you may need
to run your requests through
ActionController. You can also use the
as your superclass (which just implements the concern).
This setting allows defining which schema will be used by default.
# app/controllers/my_controller.rb self.gql_schema = 'GraphQL::MySchema' # OR self.gql_schema = GraphQL::MySchema
The namespace is not supported because the class must be loaded before the schema can be found.
Here is the list of actions that are implemented by the concern:
It will use the helpers provided to execute a request for the
It will print a plain GraphQL document that represents everything that is defined in the schema.
It will render a GraphiQL console for the underlying schema.
Identifies if the request should be threated as a compiled request.
It will render a JSON with the response of the
It will collect the necessary pieces using other helpers and then execute the
request for the provided
document. You can provide
the following named arguments:
It will resolve the underlying schema from
or by attempting to find a schema with the same name as your application.
It returns the GraphQL document as
gql_query_cache_key(key = nil, version = nil)
Attempt to build build a cache key for cached requests.
You can provide the
key, or it will be fetched from
version, or it will be fetched from
It returns the name for the GraphQL operation as
params[:operationName] || params[:operation_name].
It returns the context for the GraphQL request. You should override this method to add your own keys to it.
gql_variables(variables = params[:variables])
It will properly parse the provided
variables, so it is a usable
Hash. For example,
if the value is a string, it will
JSON.parse(variables), and if it is
controller parameters, it will
gql_describe_schema(schema = gql_schema)
It will generate the GraphQL string document of the provided
It will provide a nice header for the
It will provide a nice footer for the
It returns the version of the Type Map.
graphiql_settings(mode = nil)
It will return the proper settings for the GraphiQL console. It supports the
You can override this method to change the