@@ -6,6 +6,22 @@ import type {
6
6
import { prepareChildResolvers } from './prepareChildResolvers' ;
7
7
import { reorderFields } from './utils/reorderFields' ;
8
8
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
+
9
25
// copy all baseTypeComposer fields to childTC
10
26
// these are the fields before calling discriminator
11
27
function copyBaseTCFieldsToChildTC (
@@ -35,7 +51,8 @@ export function composeChildTC<TSource, TContext>(
35
51
childTC : ObjectTypeComposer < TSource , TContext > ,
36
52
opts : ComposeWithMongooseDiscriminatorsOpts < TContext >
37
53
) : ObjectTypeComposer < TSource , TContext > {
38
- const composedChildTC = copyBaseTCFieldsToChildTC ( baseDTC , childTC ) ;
54
+ let composedChildTC = copyBaseTcRelationsToChildTc ( baseDTC , childTC ) ;
55
+ composedChildTC = copyBaseTCFieldsToChildTC ( baseDTC , composedChildTC ) ;
39
56
40
57
composedChildTC . addInterface ( baseDTC . getDInterface ( ) ) ;
41
58
0 commit comments