Skip to content

Nested query filtering #1047

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

Closed
jeggy opened this issue Sep 28, 2017 · 2 comments
Closed

Nested query filtering #1047

jeggy opened this issue Sep 28, 2017 · 2 comments

Comments

@jeggy
Copy link

jeggy commented Sep 28, 2017

How can one get the result of more than just one level up and filter by multiple levels?

I created minimal example repository showing this problem

For example with this query:

{
  country(id: 2) {
    id
    name
    stores {
      id
      name
      cars {
        id
        model
        storeId
        countryId
}}}}

I only want to get the cars that are connected to that store and country. But the country query is two levels up, so I don't have access to the result of it in the resolver.

@lxjwlt
Copy link

lxjwlt commented Oct 9, 2017

+1 graphql/graphql-spec#88

@leebyron
Copy link
Contributor

leebyron commented Dec 7, 2017

Ensure the values returned from stores includes information about the country they relate to, such that when querying cars on each store, you'll have that context available.

Alternatively, if each store is unique and may appear in multiple country, then cars will only be relative to each unique store. If you care to filter them down to country, perhaps you should use a field argument like cars(inCountry: 2)

In other words, this should not be solved by looking back in the query but instead by making sure you have the appropriate data in your data model.

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