From 9b27fd94ec24c2920c7c711ec9572d11b4ac9db9 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Mon, 8 Jul 2019 11:37:11 -0700 Subject: [PATCH] Fix casting?? --- lib/graphql/client/definition.rb | 10 ++++++++-- lib/graphql/client/schema/object_type.rb | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/graphql/client/definition.rb b/lib/graphql/client/definition.rb index 780766f..665b4cb 100644 --- a/lib/graphql/client/definition.rb +++ b/lib/graphql/client/definition.rb @@ -117,8 +117,14 @@ module GraphQL end when GraphQL::Client::Schema::ObjectType::WithDefinition case obj - when nil, schema_class.klass - obj + when schema_class.klass + if obj.definer == schema_class + obj + else + cast_object(obj) + end + when nil + nil when Hash schema_class.new(obj, errors) else diff --git a/lib/graphql/client/schema/object_type.rb b/lib/graphql/client/schema/object_type.rb index 78a2d4e..1d2479e 100644 --- a/lib/graphql/client/schema/object_type.rb +++ b/lib/graphql/client/schema/object_type.rb @@ -24,6 +24,8 @@ module GraphQL end module Defined + attr_reader :definer + def initialize(data = {}, errors = Errors.new, definer) super(data, errors) @definer = definer @@ -59,7 +61,7 @@ module GraphQL include BaseType include ObjectType - attr_reader :defined_fields, :definition, :spreads + attr_reader :klass, :defined_fields, :definition, :spreads def type @klass.type