Skip to content

Commit 80a9510

Browse files
committed
Change DbLabels class filter to look for normal gql class defs
1 parent fe7660d commit 80a9510

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/common/resource.dto.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
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';
23
import {
34
cached,
45
type FnLike,
56
mapValues,
67
setInspectOnClass,
78
setToJson,
89
} from '@seedcompany/common';
10+
import { createMetadataDecorator } from '@seedcompany/nest';
911
import { LazyGetter as Once } from 'lazy-get-decorator';
1012
import { DateTime } from 'luxon';
1113
import { keys as keysOf } from 'ts-transformer-keys';
@@ -27,6 +29,11 @@ import { getParentTypes } from './parent-types';
2729
import { type MaybeSecured, type SecuredProps } from './secured-property';
2830
import { type AbstractClassType } from './types';
2931

32+
const GqlClassType = createMetadataDecorator({
33+
key: CLASS_TYPE_METADATA,
34+
setter: (type: ClassTypeVal) => type,
35+
});
36+
3037
const hasTypename = (value: unknown): value is { __typename: string } =>
3138
value != null &&
3239
typeof value === 'object' &&
@@ -282,7 +289,13 @@ export class EnhancedResource<T extends ResourceShape<any>> {
282289
@Once()
283290
get dbLabels() {
284291
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+
) {
286299
return [];
287300
}
288301
const declared = DbLabel.getOwn(cls);

0 commit comments

Comments
 (0)