# Filter nodes by connected nodes?

**URL:** <https://discuss.dgraph.io/t/filter-nodes-by-connected-nodes/13998>\
**Category:** GraphQL\
**Tags:** graphql, kind:question, dgraph, area:querylang:vars, knowledge-base\
**Created:** [May 3, 2021, 10:14pm UTC](https://discuss.dgraph.io/t/filter-nodes-by-connected-nodes/13998 "2021-05-03T22:14:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Davey](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/davey/32/8005_2.png) [@Davey](https://discuss.dgraph.io/u/Davey)\
**Post date:** [May 3, 2021, 10:14pm UTC](https://discuss.dgraph.io/t/filter-nodes-by-connected-nodes/13998/1 "2021-05-03T22:14:37Z")

</div>

I have a knowledge graph, where each **Idea** (graphql type) represents an idea and each **Relation** (graphql type) represents an edge (connection) between ideas.

In a query, is it possible to filter nodes by properties of nodes to which they are connected?

More concretely: I have particular **Idea** representing the category “people” and another representing “from Dallas.” Any particular person or thing _P_ in the knowledge web is represented by an **Idea** node. _P_ is connected to the “people” and/or “from Dallas” ideas whenever _P_ is a person or from Dallas, respectively.

Is there a query that would fetch nodes (Ideas) representing people from Dallas?

I only see, from GraphQL and DGraph documentation and from Dgraph’s auto-generated operations (based on my schema), how to write simpler queries—queries based only on _properties_ of the type which I am querying, rather than connected nodes.

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [May 3, 2021, 10:44pm UTC](https://discuss.dgraph.io/t/filter-nodes-by-connected-nodes/13998/2 "2021-05-03T22:44:05Z")

</div>

It is possible with DQL in a single query. It is possible right now in GraphQL with multiple queries, but there is a RFC and work being done towards this:

> [@RFC: Nested Filters in GraphQL](http://discuss.hypermode.com/t/rfc-nested-filters-in-graphql/13560):
>
> Motivation There are many requests from the community to add nested filters in GraphQL and it’s also one of the feature which can add more flexibility and value in our GraphQL implementation. Nested Filters like below are not supported in GraphQL . query { queryAuthor( filter: { name: { eq: "Alice" }, or: { posts: { postID: ["0x1", "0x2"] } } } ) { name posts { title } } } Although in DQL this Query is possible using var blocks like below query { post1 as var(…

---

<div class="post-metadata">

**Author:** ![Davey](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/davey/32/8005_2.png) [@Davey](https://discuss.dgraph.io/u/Davey)\
**Post date:** [May 4, 2021, 5:29pm UTC](https://discuss.dgraph.io/t/filter-nodes-by-connected-nodes/13998/3 "2021-05-04T17:29:47Z")

</div>

Ok, thank you–nested filters in GraphQL would be helpful.
