# Query disease for descendants

**URL:** <https://community.opentargets.org/t/query-disease-for-descendants/1498>\
**Category:** GraphQL API\
**Created:** [22 July 2024 16:44 UTC](https://community.opentargets.org/t/query-disease-for-descendants/1498 "2024-07-22T16:44:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vittorio\_lembo](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@Vittorio\_lembo](https://community.opentargets.org/u/Vittorio_lembo)\
**Post date:** [22 July 2024 16:44 UTC](https://community.opentargets.org/t/query-disease-for-descendants/1498/1 "2024-07-22T16:44:32Z")

</div>

Hi everyone,

I’m trying to query a list of selected diseases for their descendants. I’ve seen from the documentation that there are different ways to query for descendants.

The first one is very simple:

query **descendants\_test** {  
disease(efoId: “EFO\_0001421”) {  
**descendants**  
}  
}

Another option is:

query **disease\_children** {  
disease(efoId: “EFO\_0001421”) {  
**children** {  
descendants  
}  
}  
}

the last option is :

query **disease\_children** {  
disease(efoId: “EFO\_0001421”) {  
**parents** {  
descendants  
}  
}  
}

These 3 options clearly return 3 different results.

These three options clearly return different results. Can you please explain to me the difference behind these queries?

Additionally, I would like to know which code is most suitable for my goal, which is to find only the direct descendants of a given disease.

Thank you so much!! 😃  
Vittorio

---

<div class="post-metadata">

**Author:** ![irene](https://dub1.discourse-cdn.com/flex017/user_avatar/community.opentargets.org/irene/32/50_2.png) [@irene](https://community.opentargets.org/u/irene)\
**Post date:** [22 July 2024 17:04 UTC](https://community.opentargets.org/t/query-disease-for-descendants/1498/2 "2024-07-22T17:04:04Z")

</div>

Hi @Vittorio_lembo!

To get the direct descendants only I’d suggest to use the `children` endpoint.

Briefly:

- `descendants` returns a list containing all the terms in the ontology tree that descend from a given term. You’ll get not only the direct descendants of your trait of interest but also the descendants of those children, and so on.
- `children` returns an object with only the direct descendants of your trait. You can fetch the ID and/or the name.
- `parents.descendants`, therefore, returns a list of objects for each parent term of your given term, including all their descendants (both direct and indirect). This is why you will find the ID you’re interested in within these lists.

For a more graphical explanation, I suggest you look at the response of this query for rheumatoid arthritis in the [API playground](https://platform.opentargets.org/api) and compare it with our [ontology widget](https://platform.opentargets.org/disease/EFO_0000685).

```auto
query diseaseAnnotation {
  disease(efoId: "EFO_0000685") {
    id
    name
    descendants
    children {
      id
    }
    parents {
      id
      descendants
    }
  }
}

```

Thank you for your question. It is our intention to improve the documentation of our API to make these questions clearer.

Best,  
Irene

---

<div class="post-metadata">

**Author:** ![Vittorio\_lembo](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@Vittorio\_lembo](https://community.opentargets.org/u/Vittorio_lembo)\
**Post date:** [24 July 2024 14:26 UTC](https://community.opentargets.org/t/query-disease-for-descendants/1498/3 "2024-07-24T14:26:10Z")

</div>

Thank you so much Irene, now it is much clearer how these functions work

Best,  
Vittorio
