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

Filter by query variable #12

Open
1moeses opened this issue Feb 20, 2019 · 3 comments
Open

Filter by query variable #12

1moeses opened this issue Feb 20, 2019 · 3 comments

Comments

@1moeses
Copy link

1moeses commented Feb 20, 2019

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 1moeses changed the title Filter by Query Variable Filter by query variable Feb 20, 2019
@BalintBernhardt
Copy link

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

@aheinze
Copy link
Member

aheinze commented Apr 17, 2019

@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 🤔

@BalintBernhardt
Copy link

Huge thanks @aheinze ! Working nicely 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants