Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poorly described parsing error #498

Open
dim-37 opened this issue Oct 8, 2024 · 0 comments
Open

Poorly described parsing error #498

dim-37 opened this issue Oct 8, 2024 · 0 comments

Comments

@dim-37
Copy link

dim-37 commented Oct 8, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant