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

Default variable value not used #4298

Closed
1 task done
jorrit opened this issue Oct 4, 2021 · 1 comment · Fixed by #4357
Closed
1 task done

Default variable value not used #4298

jorrit opened this issue Oct 4, 2021 · 1 comment · Fixed by #4357
Assignees
Labels
🐛 bug Something isn't working 🌶️ hot chocolate
Milestone

Comments

@jorrit
Copy link
Contributor

jorrit commented Oct 4, 2021

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

In Hot Chocolate v11 I could skip a variable with a default value, like in this query:

query test($a: Boolean = true, $b: Boolean = true) {
  apiInformation {
    version @include(if: $a)
    startDate @include(if: $b)
  }
}

In v12, this doesn't work

Steps to reproduce

  1. Execute a query with a default value.
  2. Observe this error:
{
  "errors": [
    {
      "message": "The variable with the name `a` does not exist."
    }
  ]
}
  1. V11 has this output:

Relevant log output

{
  "data": {
    "apiInformation": {
      "version": "1.0.0.417",
      "startDate": "2021-10-04T09:34:52.186+02:00"
    }
  }
}

Additional Context?

No response

Product

Hot Chocolate

Version

12.0.1

@jorrit jorrit added the 🐛 bug Something isn't working label Oct 4, 2021
@jorrit
Copy link
Contributor Author

jorrit commented Oct 4, 2021

Extra note: when the variables are required, the following error is given in V12:

{
  "errors": [
    {
      "message": "Variable `a` is required.",
      "locations": [
        {
          "line": 1,
          "column": 12
        }
      ],
      "extensions": {
        "code": "HC0018",
        "variable": "a"
      }
    }
  ]
}

With V11, that query worked as well.

@michaelstaib michaelstaib added this to the 12.1.0 milestone Oct 4, 2021
@michaelstaib michaelstaib self-assigned this Oct 29, 2021
@michaelstaib michaelstaib linked a pull request Oct 29, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🌶️ hot chocolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants