Class: Types::BaseArgument
- Inherits:
-
GraphQL::Schema::Argument
- Object
- GraphQL::Schema::Argument
- Types::BaseArgument
- Includes:
- Gitlab::Graphql::Deprecations
- Defined in:
- app/graphql/types/base_argument.rb
Constant Summary collapse
- MAX_ARRAY_SIZE =
Default maximum size for array arguments This provides automatic validation for array arguments during the transition period while we add explicit validates: { length: { maximum: … } } to all array arguments.
Recommended usage (explicit validation):
argument :items, [GraphQL::Types::String], validates: { length: { maximum: MAX_ARRAY_SIZE } }, description: "Items (maximum is #{MAX_ARRAY_SIZE})."Fallback (automatic validation):
argument :items, [GraphQL::Types::String] # Automatically limited to MAX_ARRAY_SIZE items 100
Instance Attribute Summary collapse
-
#doc_reference ⇒ Object
readonly
Returns the value of attribute doc_reference.
Instance Method Summary collapse
-
#initialize(*args, **kwargs, &block) ⇒ BaseArgument
constructor
A new instance of BaseArgument.
Methods included from Gitlab::Graphql::Deprecations
Constructor Details
#initialize(*args, **kwargs, &block) ⇒ BaseArgument
Returns a new instance of BaseArgument.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/graphql/types/base_argument.rb', line 23 def initialize(*args, **kwargs, &block) @doc_reference = kwargs.delete(:see) # GraphQL-Ruby can pass type in two ways: # 1. As second positional arg: argument(:name, Type, ...) # 2. As keyword arg: argument(:name, type: Type, ...) argument_type = kwargs[:type] || args[1] validates_option = kwargs[:validates] # Add automatic array size validation if no explicit length validation exists add_automatic_array_validation!(kwargs) if add_validation?(argument_type, validates_option) super(*args, **kwargs, &block) end |
Instance Attribute Details
#doc_reference ⇒ Object (readonly)
Returns the value of attribute doc_reference.
21 22 23 |
# File 'app/graphql/types/base_argument.rb', line 21 def doc_reference @doc_reference end |