MichalLytek / MichalLytek/type-graphql

Support for __typename

Open
#181 5 comments 19 reactions 1 assignee Claimed by @MichalLytek View on GitHub
Enhancement :new:
Dominant language
TypeScript
Stars
8.1k
Forks
672
PR merge metrics
No merged PRs in 30d

Description

Right now, for interfaces and unions, TypeGraphQL determines the type of the returned value using `foo instanceof Foo`. This force to use class instances in every case where interfaces or unions are returned.

But this might be problematic in some cases, so it could just fallback to the `__typename` based detection for the easier cooperation with plain objects.

### Side note
Also `resolveType` implementation in unions could be omitted as:
> Optionally provide a custom type resolver function. If one is not provided, the default implementation will call isTypeOf on each implementing Object type.

Or maybe even better, for better compatibility, it should allow providing own `resolveType` function in interface and union decorators/creators.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.