Class: GraphQL::Argument
  
  
  
  
Defined Under Namespace
  
    
      Modules: DefaultPrepare
    
  
    
  
  
    
      Constant Summary
      collapse
    
    
      
        - NO_DEFAULT_VALUE =
          
  
 
- Object.new 
Instance Attribute Summary collapse
  
  
    
      Class Method Summary
      collapse
    
    
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  #define, #deprecated_define, #metadata, #redefine
  Constructor Details
  
    
  
  
    Returns a new instance of Argument.
   
 
  
  
    | 
20
21
22 | # File 'lib/graphql/argument.rb', line 20
def initialize
  @prepare_proc = DefaultPrepare
end | 
 
  
 
  
    Instance Attribute Details
    
      
      
      
  
  
    #as  ⇒ Object 
  
  
  
  
  
    | 
8
9
10 | # File 'lib/graphql/argument.rb', line 8
def as
  @as
end | 
 
    
      
      
      
  
  
    #ast_node  ⇒ Object 
  
  
  
  
  
    | 
9
10
11 | # File 'lib/graphql/argument.rb', line 9
def ast_node
  @ast_node
end | 
 
    
      
      
      
  
  
    #default_value  ⇒ Object 
  
  
  
  
  
    | 
7
8
9 | # File 'lib/graphql/argument.rb', line 7
def default_value
  @default_value
end | 
 
    
      
      
      
  
  
    #deprecation_reason  ⇒ Object 
  
  
  
  
  
    | 
8
9
10 | # File 'lib/graphql/argument.rb', line 8
def deprecation_reason
  @deprecation_reason
end | 
 
    
      
      
      
  
  
    #description  ⇒ Object 
  
  
  
  
  
    | 
8
9
10 | # File 'lib/graphql/argument.rb', line 8
def description
  @description
end | 
 
    
      
      
      
  
  
    #method_access  ⇒ Object 
  
  
  
  
  
    | 
10
11
12 | # File 'lib/graphql/argument.rb', line 10
def method_access
  @method_access
end | 
 
    
      
      
      
  
  
    #name  ⇒ String 
  
  
    Also known as:
    graphql_name
    
  
  
  
    | 
47
48
49 | # File 'lib/graphql/argument.rb', line 47
def name
  @name
end | 
 
    
   
  
    Class Method Details
    
      
  
  
    .deep_stringify(val)  ⇒ 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.
   
 
  
  
    | 
116
117
118
119
120
121
122
123
124
125
126
127
128
129 | # File 'lib/graphql/argument.rb', line 116
def self.deep_stringify(val)
  case val
  when Array
    val.map { |v| deep_stringify(v) }
  when Hash
    new_val = {}
    val.each do |k, v|
      new_val[k.to_s] = deep_stringify(v)
    end
    new_val
  else
    val
  end
end | 
 
    
      
  
  
    .from_dsl(name, type_or_argument = nil, description = nil, default_value: NO_DEFAULT_VALUE, as: nil, prepare: DefaultPrepare, **kwargs, &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.
   
 
  
  
    | 
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113 | # File 'lib/graphql/argument.rb', line 90
def self.from_dsl(name, type_or_argument = nil, description = nil, default_value: NO_DEFAULT_VALUE, as: nil, prepare: DefaultPrepare, **kwargs, &block)
  name_s = name.to_s
    description && kwargs[:description] ||= description
  kwargs[:name] ||= name_s
  kwargs[:default_value] ||= default_value
  kwargs[:as] ||= as
  unless prepare == DefaultPrepare
    kwargs[:prepare] ||= prepare
  end
  if !type_or_argument.nil? && !type_or_argument.is_a?(GraphQL::Argument)
        kwargs[:type] = type_or_argument
  end
  if type_or_argument.is_a?(GraphQL::Argument)
    type_or_argument.redefine(**kwargs, &block)
  else
    GraphQL::Argument.define(**kwargs, &block)
  end
end | 
 
    
   
  
    Instance Method Details
    
      
  
  
    #default_value?  ⇒ Boolean 
  
  
  
  
    | 
28
29
30 | # File 'lib/graphql/argument.rb', line 28
def default_value?
  !!@has_default_value
end | 
 
    
      
  
  
    #expose_as  ⇒ String 
  
  
  
  
    Returns The name of this argument inside resolve functions.
   
 
  
    | 
62
63
64 | # File 'lib/graphql/argument.rb', line 62
def expose_as
  @expose_as ||= (@as || @name).to_s
end | 
 
    
      
  
  
    #initialize_copy(other)  ⇒ Object 
  
  
  
  
  
    | 
24
25
26 | # File 'lib/graphql/argument.rb', line 24
def initialize_copy(other)
  @expose_as = nil
end | 
 
    
      
  
  
    #keyword  ⇒ Object 
  
  
  
  
    Backport this to support legacy-style directives
   
 
  
 
    
      
  
  
    #method_access?  ⇒ Boolean 
  
  
  
  
    | 
32
33
34
35 | # File 'lib/graphql/argument.rb', line 32
def method_access?
    @method_access != false
end | 
 
    
      
  
  
    #prepare(value, ctx)  ⇒ Object 
  
  
  
  
    Returns The prepared value for this argument or value itself if no prepare function exists.
   
 
  
    | 
74
75
76 | # File 'lib/graphql/argument.rb', line 74
def prepare(value, ctx)
  @prepare_proc.call(value, ctx)
end | 
 
    
      
  
  
    #prepare=(prepare_proc)  ⇒ Object 
  
  
  
  
    Assign a prepare function to prepare this argument’s value before resolve functions are called.
   
 
  
    | 
80
81
82 | # File 'lib/graphql/argument.rb', line 80
def prepare=(prepare_proc)
  @prepare_proc = BackwardsCompatibility.wrap_arity(prepare_proc, from: 1, to: 2, name: "Argument#prepare(value, ctx)")
end | 
 
    
      
  
  
    Returns the input type for this argument.
   
 
 
    
      
  
  
    #type=(new_input_type)  ⇒ Object 
  
  
  
  
    | 
51
52
53
54 | # File 'lib/graphql/argument.rb', line 51
def type=(new_input_type)
  @clean_type = nil
  @dirty_type = new_input_type
end | 
 
    
      
  
  
    #type_class  ⇒ Object 
  
  
  
  
  
    | 
84
85
86 | # File 'lib/graphql/argument.rb', line 84
def type_class
  metadata[:type_class]
end |