Overview
Rails GraphQL provides extensive configuration options to customize behavior across your application. Configuration is set globally using theRails::GraphQL.configure block.
Configuration Options
Version Control
Helps track when objects were cached and registered. Cached objects with mismatching versions need to be upgraded or reloaded. Set this to your commit hash. TypeMap uses only the first 8 characters.
Caching
The instance responsible for caching all information generated by requests. Maps automatically to
Rails.cache if kept as nil. Can also be set per Schema.Fallback cache when Rails cache is not properly defined or set to use a NullStore. Sets itself up with a memory store because cache is crucial, especially for subscriptions.
The prefix key for all cache entries for GraphQL cached items.
File Structure
List of nested paths inside the graphql folder that do not require their own namespace.
Logging
Similar to ActiveRecord verbose logs, shows the path of the file that started a GraphQL request.
List of parameters to omit from the logger when running a GraphQL request. These values are displayed better in the internal runtime logger controller.
Identical to Rails application filter_parameters, but exclusive for GraphQL operations. List of parameters to display as filtered in the logs. When nil, uses the same as the Rails application.
ActiveRecord Integration
List of all supported ActiveRecord adapters. When an adapter is supported, it maps database types into GraphQL types using proper aliases and provides methods to map model attributes to their equivalent fields.
Type Configuration
Suffix added automatically to all Input type objects. Prevents situations like
PointInputInput. Change this if your inputs have a different suffix.Set if the server should allow strings to be used as input for ENUM inputs. Operations will support quotes for ENUM values embedded in documents (heredoc won’t be accepted).
Schema Settings
Introspection is disabled by default. Recommended to only use introspection during development and tests, never in production. Can also be set per schema.
Names of the schema/operations types. The single underscore prefix prevents conflicts with application objects named Subscription, Query, etc.
Response Format
For performance purposes, this gem implements a JsonCollector. Disable this if you prefer standard hash-to-string serialization provided by ActiveSupport. Can also be set per Schema.
Default expected output type of GraphQL requests. String combined with
enable_string_collector has the best performance. On the console, automatically shifts to Hash. Can also be set per Schema.Specifies if operation results should be encoded with
ActiveSupport::JSON#encode instead of the default JSON#generate.Callbacks
Enable the ability of a callback to inject arguments dynamically into the calling method.
Enable the ability of a callback to inject named arguments dynamically into the calling method.
Import & I18n
When importing fields from modules or other objects, a warning is displayed for elements that couldn’t be correctly imported. Change this to silence such warnings.
Enable defining descriptions of any object, field, or argument using I18n. Recommended for multi-language documentation.
List of scopes used to locate I18n descriptions. Supports interpolation with namespace, kind, parent, and name variables.
Request Strategies
List of execution strategies. Applications can add their own by appending a class, preferably as a string. Can also be set per Schema.
Sources & Providers
List of all possible ruby-to-graphql compatible sources.
List of all available subscription providers.
Default subscription provider for all schemas. Can also be set per Schema.
Default value for fields about their ability to be broadcasted. Can also be set per Schema.
Known Dependencies
List of known dependencies that can be requested and included in any Schema. Best place for other gems to add their own resources and allow users to enable them.
Input Parsing
Method used to parse literal input values when provided as Hash.
JSON.parse only supports keys wrapped in quotes. Use Psych.method(:safe_load) to support keys without quotes (closer to YAML). Can assign a proc to parse values any other way.Mapping for internal parameters and where they should be taken from. Supports nested values using dot notation.
Logger
Access the GraphQL logger:ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT))). Configure with config.logger.