I have a database that consists of the following 3 entries:
{
"username": "negger",
"firstName": "Arnold"
},
{
"username": "jonsnow",
"firstName": "Jon"
},
{
"username": "tonystark",
"firstName": "Tony"
}
In my GraphQL Playground (https://dev.schandillia.com/graphql), you can run the following query:
{
users (where: {username: "jonsnow"}) {
username
firstName
}
}
And it'll return the matching data as you'd expect:
{
"data": {
"users": [
{
"username": "jonsnow",
"firstName": "Jon"
}
]
}
}
However, if you try using query variables in order to dynamically lookup entries by username
, the where
clause is simply ignored! Here's the dynamic query I'm running:
query users($username: String!) {
users(where: {username: $username}) {
username
firstName
}
}
And here's the query variable definition:
{
"username": "jonsnow"
}
My question is, what sorcery is this? Why wouldn't the playground client respect query variables even when the value being passed exists!