From 466dae394d40dac5671283c3da67247386e08360 Mon Sep 17 00:00:00 2001 From: marcus-sa Date: Fri, 15 Mar 2024 14:17:02 +0100 Subject: [PATCH] fix(core): optional inputs --- packages/core/src/lib/types-builder.ts | 6 +++--- packages/core/src/lib/utils.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/src/lib/types-builder.ts b/packages/core/src/lib/types-builder.ts index 2a6caf8..f421476 100644 --- a/packages/core/src/lib/types-builder.ts +++ b/packages/core/src/lib/types-builder.ts @@ -107,7 +107,7 @@ import { getTypeName, hasDecorator, isAsyncIterable, - isParameterNullable, + isPropertyOrParameterNullable, maybeUnwrapPromiseLikeType, maybeUnwrapSubscriptionReturnType, requireTypeName, @@ -726,7 +726,7 @@ export class TypesBuilder { return argsParameters.reduce((args, parameter) => { let type = this.createInputType(parameter.type); - if (!isParameterNullable(parameter)) { + if (!isPropertyOrParameterNullable(parameter)) { type = new GraphQLNonNull(type); } @@ -746,7 +746,7 @@ export class TypesBuilder { return Object.fromEntries( reflectionClass.getProperties().map(property => { let type = this.createOutputType(property.type); - if (!property.isOptional() && !property.isNullable()) { + if (!isPropertyOrParameterNullable(property)) { type = new GraphQLNonNull(type); } diff --git a/packages/core/src/lib/utils.ts b/packages/core/src/lib/utils.ts index 8c7d1bb..d810891 100644 --- a/packages/core/src/lib/utils.ts +++ b/packages/core/src/lib/utils.ts @@ -93,7 +93,7 @@ export function filterReflectionParametersMetaAnnotationsForArguments( return argsParameters; } -export function isParameterNullable(parameter: ReflectionParameter): boolean { +export function isPropertyOrParameterNullable(parameter: ReflectionProperty | ReflectionParameter): boolean { return parameter.isOptional() || isNullable(parameter.type); }