@@ -6,6 +6,22 @@ import type {
66import { prepareChildResolvers } from './prepareChildResolvers' ;
77import { reorderFields } from './utils/reorderFields' ;
88
9+ function copyBaseTcRelationsToChildTc (
10+ baseDTC : ObjectTypeComposer < any , any > ,
11+ childTC : ObjectTypeComposer < any , any >
12+ ) {
13+ const relations = baseDTC . getRelations ( ) ;
14+ const childRelations = childTC . getRelations ( ) ;
15+ Object . keys ( relations ) . forEach ( ( name ) => {
16+ if ( childRelations [ name ] ) {
17+ return ;
18+ }
19+ childTC . addRelation ( name , relations [ name ] as any ) ;
20+ } ) ;
21+
22+ return childTC ;
23+ }
24+
925// copy all baseTypeComposer fields to childTC
1026// these are the fields before calling discriminator
1127function copyBaseTCFieldsToChildTC (
@@ -35,7 +51,8 @@ export function composeChildTC<TSource, TContext>(
3551 childTC : ObjectTypeComposer < TSource , TContext > ,
3652 opts : ComposeWithMongooseDiscriminatorsOpts < TContext >
3753) : ObjectTypeComposer < TSource , TContext > {
38- const composedChildTC = copyBaseTCFieldsToChildTC ( baseDTC , childTC ) ;
54+ let composedChildTC = copyBaseTcRelationsToChildTc ( baseDTC , childTC ) ;
55+ composedChildTC = copyBaseTCFieldsToChildTC ( baseDTC , composedChildTC ) ;
3956
4057 composedChildTC . addInterface ( baseDTC . getDInterface ( ) ) ;
4158
0 commit comments