Skip to content

Commit 231150f

Browse files
Andrii Chebukinxperiandri
authored andcommitted
Implemented check that ValueOption returned from scalar coercion is allowed
1 parent 2004dab commit 231150f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/FSharp.Data.GraphQL.Server/Values.fs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,16 @@ let rec internal coerceVariableValue
322322
| Ok null when isNullable -> Ok null
323323
// TODO: Capture position in the JSON document
324324
| Ok null -> createNullError originalTypeDef
325+
| Ok value when not isNullable ->
326+
let ``type`` = value.GetType()
327+
if
328+
``type``.IsValueType &&
329+
``type``.FullName.StartsWith ReflectionHelper.ValueOptionTypeName &&
330+
value = Activator.CreateInstance ``type``
331+
then
332+
createNullError originalTypeDef
333+
else
334+
Ok value
325335
| result ->
326336
result |> Result.mapError (List.map (mapInputError varDef inputObjectPath objectFieldErrorDetails))
327337
| Nullable (InputObject innerdef) ->

0 commit comments

Comments
 (0)