Sha256: d128326e04ce5578be59bd7d10ee8c28e0925237a4e925ff987d4024929dd550

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

# Used for defined arguments ({Field}, {InputObjectType})
#
# @example defining an argument for a field
#   GraphQL::Field.define do
#     # ...
#     argument :favoriteFood, types.String, "Favorite thing to eat", default_value: "pizza"
#   end
#
# @example defining an input field for an {InputObjectType}
#   GraphQL::InputObjectType.define do
#     input_field :newName, !types.String
#   end
#
class GraphQL::Argument
  attr_accessor :name, :type, :description, :default_value

  include GraphQL::DefinitionHelpers::DefinedByConfig

  # This object is `self` when you're defining arguments with a block.
  # @example `argument` helper's `self` is a DefinitionConfig
  #
  #   argument :name do
  #     puts self.class.name
  #   end
  #   # => GraphQL::Argument::DefinitionConfig
  #
  class DefinitionConfig
    extend GraphQL::DefinitionHelpers::Definable
    attr_definable :type, :description, :default_value, :name

    def to_instance
      GraphQL::Argument.new(
        type: type,
        description: description,
        default_value: default_value,
        name: name,
      )
    end
  end

  def initialize(type: nil, description: nil, default_value: nil, name: nil)
    @type = type
    @description = description,
    @default_value = default_value
    @name = name
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
graphql-0.5.0 lib/graph_ql/argument.rb