Skip to content

Commit ea9aca1

Browse files
committed
Add ProjectFilters.partnerships
1 parent 640c90c commit ea9aca1

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/common/filter-field.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { applyDecorators } from '@nestjs/common';
2-
import { Field } from '@nestjs/graphql';
2+
import { Field, FieldOptions } from '@nestjs/graphql';
33
import { Type } from 'class-transformer';
44
import { ValidateNested } from 'class-validator';
55
import { Constructor, HasRequiredKeys } from 'type-fest';
@@ -15,14 +15,15 @@ export const FilterField = <T extends object>(
1515
* There are no external fields on the filter, so don't expose to GQL.
1616
*/
1717
internal?: boolean;
18-
},
18+
} & Pick<FieldOptions, 'description'>,
1919
): PropertyDecorator =>
2020
applyDecorators(
2121
...(options?.internal
2222
? []
2323
: [
2424
Field(type as unknown as () => Constructor<T>, {
2525
nullable: true,
26+
description: options?.description,
2627
}),
2728
]),
2829
Type(type),

src/components/project/dto/list-projects.dto.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ export abstract class ProjectFilters {
109109

110110
readonly userId?: ID;
111111

112+
@FilterField(() => PartnershipFilters, {
113+
description: 'Only projects with _any_ partnerships matching these filters',
114+
})
115+
readonly partnerships?: PartnershipFilters & {};
116+
112117
@FilterField(() => PartnershipFilters)
113118
readonly primaryPartnership?: PartnershipFilters & {};
114119

src/components/project/project-filters.query.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ export const projectFilters = filter.define(() => ProjectFilters, {
100100
.with('*')
101101
.where({ sensitivity: inArray(value) })
102102
: query,
103+
partnerships: filter.sub(() => partnershipFilters)((sub) =>
104+
sub
105+
.with('node as project')
106+
.match([
107+
node('project'),
108+
relation('out', '', 'partnership', ACTIVE),
109+
node('node', 'Partnership'),
110+
]),
111+
),
103112
primaryPartnership: filter.sub(() => partnershipFilters)((sub) =>
104113
sub
105114
.with('node as project')

0 commit comments

Comments
 (0)