Sha256: 04e3b90f03577e5910ae0fad995479af23ac801eb75c8c3cced67ea34a3742ef

Contents?: true

Size: 627 Bytes

Versions: 29

Compression:

Stored size: 627 Bytes

Contents

# Given an object, a type name (from the query) and a type object,
# Return the type that should be used for `object`
# or Return `nil` if it's a mismatch
class GraphQL::Query::TypeResolver
  attr_reader :type
  def initialize(target, child_type, parent_type)
    @type = if child_type.nil?
      nil
    elsif parent_type.kind.union?
      parent_type.resolve_type(target)
    elsif child_type.kind.union? && child_type.include?(parent_type)
      parent_type
    elsif child_type.kind.interface?
      child_type.resolve_type(target)
    elsif child_type == parent_type
      parent_type
    else
      nil
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
graphql-0.12.1 lib/graphql/query/type_resolver.rb
graphql-0.12.0 lib/graphql/query/type_resolver.rb
graphql-0.11.1 lib/graphql/query/type_resolver.rb
graphql-0.11.0 lib/graphql/query/type_resolver.rb
graphql-0.10.9 lib/graphql/query/type_resolver.rb
graphql-0.10.8 lib/graphql/query/type_resolver.rb
graphql-0.10.7 lib/graphql/query/type_resolver.rb
graphql-0.10.6 lib/graphql/query/type_resolver.rb
graphql-0.10.5 lib/graphql/query/type_resolver.rb
graphql-0.10.4 lib/graphql/query/type_resolver.rb
graphql-0.10.3 lib/graphql/query/type_resolver.rb
graphql-0.10.2 lib/graphql/query/type_resolver.rb
graphql-0.10.1 lib/graphql/query/type_resolver.rb
graphql-0.10.0 lib/graphql/query/type_resolver.rb
graphql-0.9.5 lib/graphql/query/type_resolver.rb
graphql-0.9.4 lib/graphql/query/type_resolver.rb
graphql-0.9.3 lib/graphql/query/type_resolver.rb
graphql-0.9.2 lib/graphql/query/type_resolver.rb
graphql-0.8.1 lib/graphql/query/type_resolver.rb
graphql-0.8.0 lib/graphql/query/type_resolver.rb