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 bb949dd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions core/src/main/scala-2/caliban/schema/SchemaDerivation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +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 (p.typeclass.canFail) (true, true)
else if ((hasNullableAnn || p.typeclass.optional)) (true, !p.typeclass.canFail)
else (false, false)
}
Types.makeField(
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/scala-3/caliban/schema/DerivationUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ private object DerivationUtils {
val hasNonNullAnn = fieldAnnotations.contains(GQLNonNullable())

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

0 comments on commit bb949dd

Please sign in to comment.