Sha256: d335a14a8ff2cdf1ac4b78f1cd752e8603918019420bd64a1d2ae9a360e33184

Contents?: true

Size: 756 Bytes

Versions: 15

Compression:

Stored size: 756 Bytes

Contents

module GraphQL
  class Query
    # 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 TypeResolver
      attr_reader :type
      def initialize(target, child_type, parent_type, query_ctx)
        @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, query_ctx)
        elsif child_type == parent_type
          parent_type
        else
          nil
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
graphql-0.18.1 lib/graphql/query/type_resolver.rb
graphql-0.18.0 lib/graphql/query/type_resolver.rb
graphql-0.17.2 lib/graphql/query/type_resolver.rb
graphql-0.17.1 lib/graphql/query/type_resolver.rb
graphql-0.17.0 lib/graphql/query/type_resolver.rb
graphql-0.16.1 lib/graphql/query/type_resolver.rb
graphql-0.16.0 lib/graphql/query/type_resolver.rb
graphql-0.15.3 lib/graphql/query/type_resolver.rb
graphql-0.15.2 lib/graphql/query/type_resolver.rb
graphql-0.14.2 lib/graphql/query/type_resolver.rb
graphql-0.15.1 lib/graphql/query/type_resolver.rb
graphql-0.15.0 lib/graphql/query/type_resolver.rb
graphql-0.14.1 lib/graphql/query/type_resolver.rb
graphql-0.14.0 lib/graphql/query/type_resolver.rb
graphql-0.13.0 lib/graphql/query/type_resolver.rb