@@ -11,13 +11,17 @@ import {
1111 RootMetadata ,
1212 TypeMetadata ,
1313} from './decorator' ;
14+ import { MetadataStorage } from './metadata-storage' ;
15+
1416import { SchemaFactoryError , SchemaFactoryErrorType } from './schema_factory' ;
1517
1618import { IoCContainer } from './ioc-container' ;
1719import { OrderByTypeFactory } from './order-by.type-factory' ;
1820import { PaginationType } from './pagination.type' ;
1921import { enumTypeFactory } from './enum.type-factory' ;
2022import { objectTypeFactory } from './object_type_factory' ;
23+ import { unionTypeFactory } from './type-factory' ;
24+
2125
2226export interface ResolverHolder {
2327 fn : Function ;
@@ -43,12 +47,15 @@ function convertType(typeFn: Function, metadata: TypeMetadata, isInput: boolean,
4347 } else if ( typeFn === Boolean ) {
4448 returnType = graphql . GraphQLBoolean ;
4549 } else if ( typeFn && typeFn . prototype && Reflect . hasMetadata ( GQ_OBJECT_METADATA_KEY , typeFn . prototype ) ) {
46- // recursively call objectFactory
47- returnType = objectTypeFactory ( typeFn , isInput ) ;
50+ // recursively call objectFactory
51+ returnType = objectTypeFactory ( typeFn , isInput ) ;
4852 }
49- } else {
53+ } else {
5054 returnType = metadata . explicitType ;
51- if ( returnType && returnType . prototype && Reflect . hasMetadata ( GQ_OBJECT_METADATA_KEY , returnType . prototype ) ) {
55+
56+ if ( returnType && returnType . prototype && MetadataStorage . containsUnionMetadata ( returnType . name ) ) {
57+ returnType = unionTypeFactory ( returnType . name , isInput ) ;
58+ } else if ( returnType && returnType . prototype && Reflect . hasMetadata ( GQ_OBJECT_METADATA_KEY , returnType . prototype ) ) {
5259 // recursively call objectFactory
5360 returnType = objectTypeFactory ( returnType , isInput ) ;
5461 } else if ( returnType && returnType . prototype && Reflect . hasMetadata ( GQ_ENUM_METADATA_KEY , returnType . prototype ) ) {
0 commit comments