Panic in GraphQL server when variable is expected to be an array, but isn't

I used the simple Task/User schema from the tutorial, then tried to do a mutation:

mutation Foobar($newuser: [AddUserInput!]!)  {
  addUser(input: $newuser) {

with a variable:

  "newuser": {
    "username": "oising",
    "name": "oisin g.",
    "tasks": []

This caused:

  "errors": [
      "message": "Internal Server Error - a panic was trapped.  This indicates a bug in the GraphQL server.  A stack trace was logged.  Please let us know by filing an issue with the stack trace."

Because the variable should be an array of AddUserInput, not a single AddUserInput.

I would expect a type error, not a panic. I’m using 20.11 standalone.

But, it isn’t a GraphQL type error according to spec:

If the value passed as an input to a list type is not a list and not the null value, then the result of input coercion is a list of size one, where the single item value is the result of input coercion for the list’s item type on the provided value

This was fixed in 20.11.1:

1 Like

Even better! It makes more sense to coerce the scalar to a single element array. Thanks for the update.

Hi @oising, I reproduced it and found that it’s a bug.
Thanks for reporting this,we will fix it soon.