GraphQLSwift / GraphQL

The Swift GraphQL implementation for macOS and Linux
MIT License
938 stars 72 forks source link

Query with default values does not work #155

Closed ZirgVoice closed 1 week ago

ZirgVoice commented 1 week ago

A recent fix addressed self-analysis with default values. It seems that queries are no longer working. I'm receiving the following error:

{
  "errors": [
    {
      "message": "Argument \"restart\" got invalid value 0.\nExpected type \"Boolean\", found 0.",
      "path": []
    }
  ]
}

The error occurs when I don't pass anything into the field that has a default value. However, when I provide data for this field, everything works fine. Query example: With an error

query Query($runRaceSessionId: ID!, $onlyPaidSims: Boolean!) {
  runRaceSession(id: $runRaceSessionId, onlyPaidSims: $onlyPaidSims)
}
{
  "runRaceSessionId": "01JAT8TRSF3F7AP97A9GCX1E1S",
  "onlyPaidSims": false
}

Without error

query Query($runRaceSessionId: ID!, $onlyPaidSims: Boolean!, $restart: Boolean!) {
  runRaceSession(id: $runRaceSessionId, onlyPaidSims: $onlyPaidSims, restart: $restart)
}
{
  "runRaceSessionId": "01JAT8TRSF3F7AP97A9GCX1E1S",
  "onlyPaidSims": false,
  "restart": false
}
NeedleInAJayStack commented 1 week ago

I believe this PR fixes your issue, can you give it a whirl and let me know? https://github.com/GraphQLSwift/GraphQL/pull/156

I've also created a Graphiti PR that adds default value tests so hopefully we can catch situations like this a bit sooner: https://github.com/GraphQLSwift/Graphiti/pull/145

ZirgVoice commented 1 week ago

I believe this PR fixes your issue, can you give it a whirl and let me know? #156

I've also created a Graphiti PR that adds default value tests so hopefully we can catch situations like this a bit sooner: GraphQLSwift/Graphiti#145

Yes. This fixes issue. Thank you very much.