Skip to content

Commit

Permalink
fix(core): optional inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-sa committed Mar 15, 2024
1 parent 4801126 commit 466dae3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/lib/types-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ import {
getTypeName,
hasDecorator,
isAsyncIterable,
isParameterNullable,
isPropertyOrParameterNullable,
maybeUnwrapPromiseLikeType,
maybeUnwrapSubscriptionReturnType,
requireTypeName,
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 466dae3

Please sign in to comment.