Overview
Input objects define a set of input fields. Input fields can be scalars, enums, or other input objects. Input types are used for complex argument structures. Inherits from:Rails::GraphQL::Type
Specification: GraphQL Input Object Type Definition
Class Attributes
The type of field class used for input fields
Valid types that can be used in input fields:
Type::EnumType::InputType::Scalar
Class Methods
gql_name
Get the GraphQL name of the input type, with optional auto-suffix.
The GraphQL name, with suffix applied based on
auto_suffix_input_objects configvalid_input?(value)
Check if a value is valid input for this input type.
The value to validate
Returns
true if the value is validdeserialize(value = nil, **value_as_hash)
Turn input into an instance of the input object.
The input value as a hash
Alternative: provide value as keyword arguments
An input object instance
build(value = nil, **value_as_hash)
Alias for deserialize.
build_defaults
Build a hash with default values for all fields.
Hash mapping field names to their default values
as_json(value)
Transform value to its JSON hash representation.
The value to serialize
Hash with GraphQL field names as keys
to_json(value)
Transform value to a JSON string.
The value to serialize
JSON string representation
Instance Methods
initialize(args = nil, **xargs)
Create a new input instance.
The deserialized arguments
Arguments as keyword parameters
args
Access the underlying arguments as an OpenStruct.
Frozen OpenStruct containing all field values
params
Get arguments as a parameter hash.
Hash with Ruby-style (underscored) keys, with nested inputs converted to params
resource(*args, **xargs, &block)
Get or create an instance of the assigned class.
Additional arguments for the assigned class constructor
Additional keyword arguments merged with params
Instance of the assigned class, or
nil if no class assignedargs_as_json
Convert all arguments to their JSON representation.
Hash with all values serialized via
as_jsonargs_to_json
Convert all arguments to a JSON string.
JSON string of all arguments
validate!(*)
Validate all field values in the input instance.
to_h
Delegate to args.to_h.
[]
Access field values by key (delegates to args).
to_global_id / to_gid / to_gid_param
Convert the input to a GlobalID representation.
GlobalID instance for this input
Instance Attributes
Stores any error that occurred when loading the assigned class
Cached instance of the assigned class
Included Modules
Helpers::WithAssignment
Allows assignment to Ruby classes via
assigned_toHelpers::WithFields
Provides field definition and management methods
Configuration
Usage Examples
Basic Input
Nested Input Objects
With Resource Mapping
Accessing Values
Special Features
Automatic Name Suffixing
Based on theauto_suffix_input_objects configuration, input type names are automatically suffixed:
Default Values
Fields can specify default values that are automatically merged during deserialization:Delegate Missing
Input instances delegate unknown methods to theresource object, allowing seamless integration with assigned classes.