Description
We use Chessie and resolver function returns a result. Then I want to unwrap that result and return value or errors as GraphQL response like this:
/// If Ok, returns value and sets messages as GraphQL operation errors
/// If Bad, returns value and sets errors as GraphQL operation errors
let handleMessages<'TSuccess,'TMessage> (ctx : ResolveFieldContext) (result : Result<'TSuccess,'TMessage>) : 'TSuccess =
let setErrors messages =
let ex = GraphQLException (ctx.ExecutionInfo.Identifier)
messages |> Seq.iteri (fun m i -> ex.Data.Add (i, m))
ctx.AddError ex
match result with
| Ok (value, messages) -> setErrors (messages); value
| Bad messages -> setErrors (messages); Unchecked.defaultof<'TSuccess>
However as long as type is not nullable, returning null produces error.
Repro steps
- Create resolver that returns
Result type of Chassie library
- Use my function to unwrap a result
Expected behavior
Ability to handle Result type and pass errors without raising an exception.
Actual behavior
nullResolverError is called and GraphQLException is returned
Known workarounds
Raise exception after resolver execution
Related information
- FSharp.Data.GraphQL.Server 1.0.5
Description
We use Chessie and resolver function returns a result. Then I want to unwrap that result and return value or errors as GraphQL response like this:
However as long as type is not nullable, returning null produces error.
Repro steps
Resulttype of Chassie libraryExpected behavior
Ability to handle
Resulttype and pass errors without raising an exception.Actual behavior
nullResolverError is called and
GraphQLExceptionis returnedKnown workarounds
Raise exception after resolver execution
Related information