Class: GraphQL::Argument

Inherits:
Object
  • Object
show all
Includes:
Define::InstanceDefinable
Defined in:
lib/graphql/argument.rb

Overview

Used for defined arguments (Field, InputObjectType)

#name must be a String.

Examples:

defining an argument for a field

GraphQL::Field.define do
  # ...
  argument :favoriteFood, types.String, "Favorite thing to eat", default_value: "pizza"
end

defining an argument for an InputObjectType

GraphQL::InputObjectType.define do
  argument :newName, !types.String
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Define::InstanceDefinable

#define, #metadata, #redefine

Instance Attribute Details

#asObject

Returns the value of attribute as.



21
22
23
# File 'lib/graphql/argument.rb', line 21

def as
  @as
end

#default_valueObject

Returns the value of attribute default_value.



21
22
23
# File 'lib/graphql/argument.rb', line 21

def default_value
  @default_value
end

#descriptionObject

Returns the value of attribute description.



21
22
23
# File 'lib/graphql/argument.rb', line 21

def description
  @description
end

#nameString

Returns The name of this argument on its Field or InputObjectType.

Returns:



38
39
40
# File 'lib/graphql/argument.rb', line 38

def name
  @name
end

#typeGraphQL::BaseType

Returns the input type for this argument.

Returns:



48
49
50
# File 'lib/graphql/argument.rb', line 48

def type
  @type
end

Instance Method Details

#default_value?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/graphql/argument.rb', line 29

def default_value?
  !!@has_default_value
end

#expose_asString

Returns The name of this argument inside resolve functions.

Returns:

  • (String)

    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