Class: GraphQL::Argument
- Inherits:
-
Object
- Object
- GraphQL::Argument
- Includes:
- Define::InstanceDefinable
- Defined in:
- lib/graphql/argument.rb
Overview
Used for defined arguments (Field, InputObjectType)
#name must be a String.
Constant Summary collapse
- NO_DEFAULT_VALUE =
Object.new
Instance Attribute Summary collapse
-
#as ⇒ Object
Returns the value of attribute as.
-
#default_value ⇒ Object
Returns the value of attribute default_value.
-
#description ⇒ Object
Returns the value of attribute description.
-
#name ⇒ String
The name of this argument on its Field or InputObjectType.
-
#type ⇒ GraphQL::BaseType
The input type for this argument.
Class Method Summary collapse
Instance Method Summary collapse
- #default_value? ⇒ Boolean
-
#expose_as ⇒ String
The name of this argument inside
resolve
functions. - #initialize_copy(other) ⇒ Object
Methods included from Define::InstanceDefinable
Instance Attribute Details
#as ⇒ Object
Returns the value of attribute as.
21 22 23 |
# File 'lib/graphql/argument.rb', line 21 def as @as end |
#default_value ⇒ Object
Returns the value of attribute default_value.
21 22 23 |
# File 'lib/graphql/argument.rb', line 21 def default_value @default_value end |
#description ⇒ Object
Returns the value of attribute description.
21 22 23 |
# File 'lib/graphql/argument.rb', line 21 def description @description end |
#name ⇒ String
Returns The name of this argument on its Field or InputObjectType.
38 39 40 |
# File 'lib/graphql/argument.rb', line 38 def name @name end |
#type ⇒ GraphQL::BaseType
Returns the input type for this argument.
48 49 50 |
# File 'lib/graphql/argument.rb', line 48 def type @type end |
Class Method Details
.from_dsl(name, type = nil, description = nil, default_value: NO_DEFAULT_VALUE, as: nil, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/graphql/argument.rb', line 59 def self.from_dsl(name, type = nil, description = nil, default_value: NO_DEFAULT_VALUE, as: nil, &block) argument = if block_given? GraphQL::Argument.define(&block) else GraphQL::Argument.new end argument.name = name.to_s type && argument.type = type description && argument.description = description if default_value != NO_DEFAULT_VALUE argument.default_value = default_value end argument.as = as argument end |
Instance Method Details
#default_value? ⇒ Boolean
29 30 31 |
# File 'lib/graphql/argument.rb', line 29 def default_value? !!@has_default_value end |
#expose_as ⇒ String
Returns The name of this argument inside resolve
functions.
53 54 55 |
# File 'lib/graphql/argument.rb', line 53 def expose_as @expose_as ||= (@as || @name).to_s end |
#initialize_copy(other) ⇒ Object
25 26 27 |
# File 'lib/graphql/argument.rb', line 25 def initialize_copy(other) @expose_as = nil end |