Sha256: f5bc3070da70efcc554c0d6bf5af227ecca126048d00994f5dd537d551ca5814

Contents?: true

Size: 1.27 KB

Versions: 12

Compression:

Stored size: 1.27 KB

Contents

module GraphQL
  # Used for defined arguments ({Field}, {InputObjectType})
  #
  # {#name} must be a String.
  #
  # @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 argument for an {InputObjectType}
  #   GraphQL::InputObjectType.define do
  #     argument :newName, !types.String
  #   end
  #
  class Argument
    include GraphQL::Define::InstanceDefinable
    accepts_definitions :name, :type, :description, :default_value
    lazy_defined_attr_accessor :type, :description, :default_value, :name

    # @!attribute name
    #   @return [String] The name of this argument on its {GraphQL::Field} or {GraphQL::InputObjectType}

    # @param new_input_type [GraphQL::BaseType, Proc] Assign a new input type for this argument (if it's a proc, it will be called after schema initialization)
    def type=(new_input_type)
      ensure_defined
      @clean_type = nil
      @dirty_type = new_input_type
    end

    # @return [GraphQL::BaseType] the input type for this argument
    def type
      @clean_type ||= begin
        ensure_defined
        GraphQL::BaseType.resolve_related_type(@dirty_type)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
graphql-1.1.0 lib/graphql/argument.rb
graphql-1.0.0 lib/graphql/argument.rb
graphql-0.19.4 lib/graphql/argument.rb
graphql-0.19.3 lib/graphql/argument.rb
graphql-0.19.2 lib/graphql/argument.rb
graphql-0.19.1 lib/graphql/argument.rb
graphql-0.19.0 lib/graphql/argument.rb
graphql-0.18.15 lib/graphql/argument.rb
graphql-0.18.14 lib/graphql/argument.rb
graphql-0.18.13 lib/graphql/argument.rb
graphql-0.18.12 lib/graphql/argument.rb
graphql-0.18.11 lib/graphql/argument.rb