Vincit / objection-graphql

GraphQL schema generator for objection.js
MIT License
307 stars 34 forks source link

range: [] doesn't seem to work with variables in graphiQL #22

Closed Trellian closed 6 years ago

Trellian commented 6 years ago

I'm trying to test a query in the GraphiQL client, but it doesn't recognize variables in the query. They are simply ignored. The OrderBy: works fine.

The query:

query getRegions ($start: Int, $end: Int) {
  iwRegions (range: [$start, $end], orderBy: name) {
    name
  }
}

with variables:

{
  "start": 0,
  "end": 4
}

returns:

{
  "data": {
    "iwRegions": [
      {
        "name": "Eastern Cape"
      },
      {
        "name": "Garden Route"
      },
      {
        "name": "Gauteng"
      },
      {
        "name": "Kwazulu Natal"
      },
      {
        "name": "Limpopo"
      },
      {
        "name": "Mpumulanga"
      },
      {
        "name": "Northern Cape"
      },
      {
        "name": "Northwest Province"
      },
      {
        "name": "Western Cape"
      }
    ]
  }
}

If I hard-code the values as follows:

query getRegions {
  iwRegions (range: [0, 4], orderBy: name) {
    name
  }
}

I get the correct response:

{
  "data": {
    "iwRegions": [
      {
        "name": "Eastern Cape"
      },
      {
        "name": "Garden Route"
      },
      {
        "name": "Gauteng"
      },
      {
        "name": "Kwazulu Natal"
      },
      {
        "name": "Limpopo"
      }
    ]
  }
}

Any ideas?

Thanks, Adrian

koskimas commented 6 years ago

Seems to be a bug. I'll fix that asap.

Thank you for an excellent issue by the way! Clear issues like this with actual data and a reproduction are very rare 👍

Trellian commented 6 years ago

Kind words indeed... Thank you for an awesome library, and happy bug-hunting :)