Skip to content

Commit 190e5eb

Browse files
committed
Support optional list with nullable items
This prevents null for the overall list property but allows nulls in the list ```ts Array<T | null> | undefined ``` This corrects the `scheduleStatus` field which previously allowed the value to be null despite missing that type
1 parent 14f2803 commit 190e5eb

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/common/optional-field.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ export function OptionalField(...args: any) {
4242
typeof args[0] === 'function' ? (args[0] as () => any) : undefined;
4343
const options: OptionalFieldOptions =
4444
(typeof args[0] === 'function' ? args[1] : args[0]) ?? {};
45-
const nilIn = options.nullable ?? options.optional ?? true;
46-
const nullOut = !!options.nullable;
45+
const nilIn =
46+
options.nullable === 'items' && options.optional
47+
? 'itemsAndList'
48+
: options.nullable ?? options.optional ?? true;
49+
const nullOut = !!options.nullable && options.nullable !== 'items';
4750
const schemaOptions = {
4851
...options,
4952
nullable: nilIn,

src/components/progress-summary/dto/progress-summary-filters.dto.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { ScheduleStatus } from './schedule-status.enum';
66
@InputType()
77
export abstract class ProgressSummaryFilters {
88
@ListField(() => ScheduleStatus, {
9-
nullable: 'itemsAndList',
9+
optional: true,
10+
nullable: 'items',
1011
description: stripIndent`
1112
Filter by schedule status.
1213
- \`[X, Y]\` will allow summaries with either X or Y status.

0 commit comments

Comments
 (0)