MichalLytek / MichalLytek/type-graphql
Support for __typename
- 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
Assessment
This issue has not been assessed yet.