Skip to content

List[Enum] Variable Coercion Error  #855

Open
@BenjaminYong

Description

@BenjaminYong

Hi there,

I have recently come upon unexpected list coercion errors for [Enum] variable values.
The error occurs when the variable value is null for no input value for the enum list.

query getUsers($userType: [UserType], $username: [String]){
  getUsers(
    userType: $userType
    username: $username
  ){
    userType
    username
  }
}

Variables

{
  "userType": null,
  "username": null
}

This results to

{
  "errors": [
    {
      "message": "mismatched input value"
    }
  ]
}

If I replace userType variable value to [] or [null], the error is gone. However, that will mean I am sending an empty list rather than a null which will impact resolver input value logic. I'd expect the null to be passed through and ignored in subgraph.
It seems that a null variable value for a [Enum] nullable input field does not work.

It does however work for [String], where I can provide a null variable value and it does not error.

The error is thrown in:
func (v *inputFieldDefaultInjectionVisitor) processObjectOrListInput(fieldType int, defaultValue []byte, typeDoc *ast.Document) ([]byte, bool, error)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions