Module: GraphQL::Schema::ResolveTypeWithType

Defined in:
lib/graphql/schema.rb

Overview

rubocop:disable Lint/DuplicateMethods

Instance Method Summary collapse

Instance Method Details

#resolve_type(type, obj, ctx) ⇒ Object



1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
# File 'lib/graphql/schema.rb', line 1333

def resolve_type(type, obj, ctx)
  first_resolved_type = if type.is_a?(Module) && type.respond_to?(:resolve_type)
    type.resolve_type(obj, ctx)
  else
    super
  end

  after_lazy(first_resolved_type) do |resolved_type|
    if resolved_type.nil? || (resolved_type.is_a?(Module) && resolved_type.respond_to?(:kind)) || resolved_type.is_a?(GraphQL::BaseType)
      resolved_type
    else
      raise ".resolve_type should return a type definition, but got #{resolved_type.inspect} (#{resolved_type.class}) from `resolve_type(#{type}, #{obj}, #{ctx})`"
    end
  end
end