Sha256: d373a611c04edfe68e2d8b86c55fa78ffac6cee79d84e43e2a7d0a4e40bca070

Contents?: true

Size: 810 Bytes

Versions: 2

Compression:

Stored size: 810 Bytes

Contents

module GraphQL
  module Define
    # Turn field configs into a {GraphQL::Field} and attach it to a {GraphQL::ObjectType} or {GraphQL::InterfaceType}
    module AssignObjectField
      def self.call(fields_type, name, type = nil, desc = nil, field: nil, deprecation_reason: nil, property: nil, complexity: nil, &block)
        if block_given?
          field = GraphQL::Field.define(&block)
        else
          field ||= GraphQL::Field.new
        end
        type && field.type = type
        desc && field.description = desc
        property && field.property = property
        complexity && field.complexity = complexity
        deprecation_reason && field.deprecation_reason = deprecation_reason
        field.name ||= name.to_s
        fields_type.fields[name.to_s] = field
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphql-0.16.1 lib/graphql/define/assign_object_field.rb
graphql-0.16.0 lib/graphql/define/assign_object_field.rb