Skip to content

Commit

Permalink
Fix not keeping semantics of .optional on custom schema
Browse files Browse the repository at this point in the history
  • Loading branch information
XiNiHa committed May 11, 2024
1 parent 61f3c6d commit 5c20b50
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ trait CommonSchemaDerivation[R] {
val hasNonNullAnn = p.annotations.contains(GQLNonNullable())

if (hasNonNullAnn) (false, false)
else if (hasNullableAnn || p.typeclass.nullable) (true, false)
else if ((hasNullableAnn || p.typeclass.optional) && !p.typeclass.canFail) (true, false)
else if (p.typeclass.canFail) (true, true)
else (false, false)
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala-3/caliban/schema/DerivationUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private object DerivationUtils {
val hasNonNullAnn = fieldAnnotations.contains(GQLNonNullable())

if (hasNonNullAnn) (false, false)
else if (hasNullableAnn || schema.nullable) (true, false)
else if ((hasNullableAnn || schema.optional) && !schema.canFail) (true, false)
else if (schema.canFail) (true, true)
else (false, false)
}
Expand Down

0 comments on commit 5c20b50

Please sign in to comment.