lib/graphql/schema/interface.rb in graphql-2.3.10 vs lib/graphql/schema/interface.rb in graphql-2.3.11

- old
+ new

@@ -80,16 +80,32 @@ end super end + # Register other Interface or Object types as implementers of this Interface. + # + # When those Interfaces or Objects aren't used as the return values of fields, + # they may have to be registered using this method so that GraphQL-Ruby can find them. + # @param types [Class, Module] + # @return [Array<Module, Class>] Implementers of this interface, if they're registered def orphan_types(*types) if types.any? - @orphan_types = types + @orphan_types ||= [] + @orphan_types.concat(types) else - all_orphan_types = @orphan_types || [] - all_orphan_types += super if defined?(super) - all_orphan_types.uniq + if defined?(@orphan_types) + all_orphan_types = @orphan_types.dup + if defined?(super) + all_orphan_types += super + all_orphan_types.uniq! + end + all_orphan_types + elsif defined?(super) + super + else + EmptyObjects::EMPTY_ARRAY + end end end def kind GraphQL::TypeKinds::INTERFACE