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

#default_valueObject

Returns the value of attribute default_value.



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

def default_value
  @default_value
end

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#nameString

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

Returns:



33
34
35
# File 'lib/graphql/argument.rb', line 33

def name
  @name
end

#typeGraphQL::BaseType

Returns the input type for this argument.

Returns:



43
44
45
# File 'lib/graphql/argument.rb', line 43

def type
  @type
end

Instance Method Details

#default_value?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/graphql/argument.rb', line 24

def default_value?
  !!@has_default_value
end