CockpitQL icon indicating copy to clipboard operation
CockpitQL copied to clipboard

Filter by query variable

Open 1moeses opened this issue 6 years ago • 3 comments

Is it actually possible to filter by query variables?

query post($id: String) {
  allPosts(filter: {_id: $id}) {
    title
    __typename
  }
}
{
  "id": "5c69be76387945700280002a4"
}

I always get an empty array:

{
  "data": {
    "allPosts": []
  }
}

even though apollo-client-dev-tools is showing me the variable

query post{
  allPosts(filter: {_id: "5c69be76387945700280002a4"}) {
    title
    __typename
  }
}

works fine.

Thanks!

1moeses avatar Feb 20 '19 21:02 1moeses

Any help would be greatly appreciated in this one! Thanks!

BalintBernhardt avatar Apr 17 '19 21:04 BalintBernhardt

@diehenne @BalintBernhardt

what seems to work:

query post($filter: JsonType) {
  allPosts(filter: $filter) {
    title
    __typename
  }
}

with variables:

{"filter": {"_id": "5c69be76387945700280002a4"}}

it seems that variables aren't resolved in a nested json 🤔

aheinze avatar Apr 17 '19 22:04 aheinze

Huge thanks @aheinze ! Working nicely 🚀

BalintBernhardt avatar Apr 17 '19 22:04 BalintBernhardt