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

List[Enum] Variable Coercion Error #855

Open
BenjaminYong opened this issue Jul 22, 2024 · 0 comments
Open

List[Enum] Variable Coercion Error #855

BenjaminYong opened this issue Jul 22, 2024 · 0 comments
Labels
internally-reviewed Internally reviewed

Comments

@BenjaminYong
Copy link
Contributor

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)

@jensneuse jensneuse added the internally-reviewed Internally reviewed label Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internally-reviewed Internally reviewed
Projects
None yet
Development

No branches or pull requests

2 participants