Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filtering nested properties in subgraph (the graph)

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
    }
  }
}
like image 227
marija Avatar asked Sep 14 '25 14:09

marija


2 Answers

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

like image 171
nezort11 Avatar answered Sep 16 '25 22:09

nezort11


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.

like image 37
jjperezaguinaga Avatar answered Sep 16 '25 21:09

jjperezaguinaga