Sha256: c920a0e7f64f3cf7faca644f46ebd8a458ec21026bcff99f3cb3465bd496abbb

Contents?: true

Size: 888 Bytes

Versions: 2

Compression:

Stored size: 888 Bytes

Contents

module GraphQL
  module Define
    # Some conveniences for definining return & argument types.
    #
    # Passed into initialization blocks, eg {ObjectType#initialize}, {Field#initialize}
    class TypeDefiner
      include Singleton

      def Int;      GraphQL::INT_TYPE;      end
      def String;   GraphQL::STRING_TYPE;   end
      def Float;    GraphQL::FLOAT_TYPE;    end
      def Boolean;  GraphQL::BOOLEAN_TYPE;  end
      def ID;       GraphQL::ID_TYPE;       end

      # Make a {ListType} which wraps the input type
      #
      # @example making a list type
      #   list_of_strings = types[types.String]
      #   list_of_strings.inspect
      #   # => "[String]"
      #
      # @param type [Type] A type to be wrapped in a ListType
      # @return [GraphQL::ListType] A ListType wrapping `type`
      def [](type)
        type.to_list_type
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphql-0.12.1 lib/graphql/define/type_definer.rb
graphql-0.12.0 lib/graphql/define/type_definer.rb