2

Is it possible to filter subgraph using "where" when properties are nested?

For example if we have query like this one, can we filter it by application name?

{
  challenges(where: {something?}) {
    challenger
    outcome
    application {
      id
      name
    }
  }
}

I have tried it like this one but it doesn't work

{
  challenges(where: {application: {name: "something"}) {
    challenger
    outcome
    application {
      id
      name
    }
  }
}
marija
  • 53
  • 6

2 Answers2

4

You can write:

{
  challenges(where: {application_: {name: "something"}) {
    challenger
    outcome
    application {
      id
      name
    }
  }
}

Notice _ after the property name

Docs: https://thegraph.com/docs/en/querying/graphql-api/#example-for-nested-entity-filtering

nezort11
  • 326
  • 1
  • 4
  • 11
1

Unfortunately, The Graph does not currently support nested queries. They currently have it on the roadmap, so my recommendation is to subscribe to their releases in their repository or check their #announcements channel in Discord.

jjperezaguinaga
  • 2,472
  • 14
  • 20
  • 1
    This answer is no longer up-to-date as of June 28, 2022. [This PR](https://github.com/graphprotocol/graph-node/pull/3184#issuecomment-1167237424) added support for nested queries. – Paul Razvan Berg Feb 27 '23 at 21:58