* First pass at custom coerce for input objects#350
* First pass at custom coerce for input objects#350njlr wants to merge 1 commit intofsprojects:devfrom
Conversation
xperiandri
left a comment
There was a problem hiding this comment.
I like what you have done. This is useful.
Also, it would be more useful to be able to return an error and pass that error to the response with error to GraphQL field mapping.
| |> Array.map (fun field -> | ||
| let valueFound = Map.tryFind field.Name map |> Option.toObj | ||
| let coercedValue = coerceVariableValue false field.TypeDef vardef valueFound (errMsg + (sprintf "in field '%s': " field.Name)) |
There was a problem hiding this comment.
| |> Array.map (fun field -> | |
| let valueFound = Map.tryFind field.Name map |> Option.toObj | |
| let coercedValue = coerceVariableValue false field.TypeDef vardef valueFound (errMsg + (sprintf "in field '%s': " field.Name)) | |
| |> Seq.map (fun field -> | |
| let valueFound = map |> Map.tryFind field.Name |> Option.toObj | |
| let coercedValue = coerceVariableValue false field.TypeDef vardef valueFound (errMsg + (sprintf "in field '%s': " field.Name)) |
Maybe it does not worth to materialize it to an array
| @@ -38,31 +38,36 @@ let rec internal compileByType (errMsg: string) (inputDef: InputDef): ExecuteInp | |||
| | Scalar scalardef -> | |||
| variableOrElse (scalardef.CoerceInput >> Option.toObj) | |||
There was a problem hiding this comment.
@jberzy can we switch this to Result<,> and pass an error to the response?
|
There is an issue I have with current scalar implementation interface ScalarDef with
member x.Name = x.Name
member x.Description = x.Description
member x.CoerceInput input = x.CoerceInput input |> Option.map box
member x.CoerceValue value = (x.CoerceValue value) |> Option.map boxThis piece is very contraintuitive member x.CoerceInput input = x.CoerceInput input |> Option.map box
member x.CoerceValue value = (x.CoerceValue value) |> Option.map box@jberzy at least XML comments with clear description required. And |
|
@xperiandri I have fleshed out this idea further: #351 |
No description provided.