FSharp.Data.GraphQL
FSharp.Data.GraphQL copied to clipboard
Poorly described parsing error
Description
I have a structure
type InputAssignRoleToUser = {
UserId : ConsoleUserId
PropertyId : PropertyId
RoleId : ConsoleUserRoleId
}
and here's its description for graphql
Define.InputObject<InputAssignRoleToUser>("InputAssignRoleToUser",
[
Define.Input("userId", ConsoleUserIdType)
Define.Input("roleId", ConsoleUserRoleIdType)
Define.Input("propertyId", PropertyIDType)
])
here is how the ConsoleUserRoleId ConsoleUserId fields are described
static member ValidStringScalar<'t>(typeName, createValid : Validator<string, 't>, toString : 't -> string, ?description: string) (*: ScalarDefinition<string, 't>*) =
let createValid : string -> ValidationResult<'t> = createValid typeName
Define.WrappedScalar
(name = typeName,
coerceInput =
(function
| Variable e when e.ValueKind = JsonValueKind.String -> e.GetString() |> createValid |> Result.mapError ValidationErrors.toIGQLErrors
| InlineConstant (StringValue s) -> s |> createValid |> Result.mapError ValidationErrors.toIGQLErrors
| Variable e -> e.GetDeserializeError typeName
| InlineConstant value -> value.GetCoerceError typeName),
coerceOutput =
(function
| :? 't as x -> Some (toString x)
| :? string as s -> s |> Some
| _ -> raise <| System.NotSupportedException ()),
?description = description)
and this is how the PropertyIDType field is described
Define.WrappedScalar
(name = typeName,
coerceInput = (function
| Variable e when e.ValueKind = JsonValueKind.String -> e.GetString() |> PropertyId.ofString |> Ok
| InlineConstant (StringValue s) -> s |> PropertyId.ofString |> Ok
| Variable e -> e.GetDeserializeError typeName
| InlineConstant value -> value.GetCoerceError typeName),
coerceOutput =
(function
| :? PropertyId as x -> Some (PropertyId.toString x)
| :? string as s -> s |> Some
| _ -> raise <| System.NotSupportedException ()),
?description = Some "I of specific property")
here is the request
mutation {
administration {
assignRoleToUser(roleToUser:
{
propertyId: "c_6740b959-030c-4779-835a-711aaf814f58",
roleId: "6740b959-030c-4779-835a-711aaf814f58",
userId: "6740b959-030c-4779-835a-711aaf814f58" })
}
}
and this is the response I'm getting
{
"documentId": -1969558732,
"errors": [
{
"message": "Index was outside the bounds of the array."
}
]
}
the error occurs somewhere after propertyId conversion but before roleId because the debugger does not enter the conversion to roleId but correctly and without errors exits from propertyId.
Expected behavior
More useful error message
Actual behavior
An error that doesn't tell me anything that can help me.
Known workarounds
Most likely it will help to replace all custom types with standard ones, but it will not solve the problem with bad error message.
Related information
Operating system: Windows 11 Branch: master (Nuget 3.0.0-ci-10873959355)