1
- import { Field , InterfaceType } from '@nestjs/graphql' ;
1
+ import { CLASS_TYPE_METADATA , Field , InterfaceType } from '@nestjs/graphql' ;
2
+ import { type ClassType as ClassTypeVal } from '@nestjs/graphql/dist/enums/class-type.enum.js' ;
2
3
import {
3
4
cached ,
4
5
type FnLike ,
5
6
mapValues ,
6
7
setInspectOnClass ,
7
8
setToJson ,
8
9
} from '@seedcompany/common' ;
10
+ import { createMetadataDecorator } from '@seedcompany/nest' ;
9
11
import { LazyGetter as Once } from 'lazy-get-decorator' ;
10
12
import { DateTime } from 'luxon' ;
11
13
import { keys as keysOf } from 'ts-transformer-keys' ;
@@ -27,6 +29,11 @@ import { getParentTypes } from './parent-types';
27
29
import { type MaybeSecured , type SecuredProps } from './secured-property' ;
28
30
import { type AbstractClassType } from './types' ;
29
31
32
+ const GqlClassType = createMetadataDecorator ( {
33
+ key : CLASS_TYPE_METADATA ,
34
+ setter : ( type : ClassTypeVal ) => type ,
35
+ } ) ;
36
+
30
37
const hasTypename = ( value : unknown ) : value is { __typename : string } =>
31
38
value != null &&
32
39
typeof value === 'object' &&
@@ -282,7 +289,13 @@ export class EnhancedResource<T extends ResourceShape<any>> {
282
289
@Once ( )
283
290
get dbLabels ( ) {
284
291
const labels = getParentTypes ( this . type ) . flatMap ( ( cls ) => {
285
- if ( ! isResourceClass ( cls ) ) {
292
+ if (
293
+ // Is declared as some gql object. i.e. avoids DataObject.
294
+ ! GqlClassType . get ( cls ) ||
295
+ // Avoid intersected classes.
296
+ // getParentTypes will give us the intersect-ees directly.
297
+ cls . name . startsWith ( 'Intersection' )
298
+ ) {
286
299
return [ ] ;
287
300
}
288
301
const declared = DbLabel . getOwn ( cls ) ;
0 commit comments