Skip to content

Commit

Permalink
consider __typename property of plain javascript objects for type
Browse files Browse the repository at this point in the history
  • Loading branch information
koenpunt committed Apr 16, 2021
1 parent 1938103 commit 8d9f530
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/schema-builder/factories/interface-definition.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ export class InterfaceDefinitionFactory {
(Type) => instance instanceof Type,
);
if (!target) {
if (Reflect.has(instance, '__typename')) {
return instance.__typename;
}
throw new ReturnTypeCannotBeResolvedError(metadata.name);
}
return this.typeDefinitionsStorage.getObjectTypeByTarget(target).type;
Expand Down

0 comments on commit 8d9f530

Please sign in to comment.