What is the best way to retrieve a list of child g...
# troubleshoot
a
What is the best way to retrieve a list of child glossary terms under a glossary node using GraphQL? The following query didn't work:
Copy code
query childGlossaryTerms {
  searchAcrossEntities(input: {
    types: [GLOSSARY_TERM], 
    query: "",
    orFilters: {
      and: {
        field: "parentNodes",
        values: ["urn:li:glossaryNode:data-type"],
      }
    }
  }) {
    searchResults {
      entity {
        urn
        type
      }
    }
  }
}
I also tried
Copy code
and: {
        field: "parentNodes.nodes[0].urn",
        values: ["urn:li:glossaryNode:data-type"],
The query below shows the structure of the glossary term/nodes.
Copy code
query getGlossaryTerm {
  glossaryTerm(urn: "urn:li:glossaryTerm:email") {
    urn
    parentNodes {
      count,
      nodes {
        urn
        type
        parentNodes {
          count,
          nodes {
            urn,
            type
          }
        }
      }
    }
  }
}
Response:
Copy code
{
  "data": {
    "glossaryTerm": {
      "urn": "urn:li:glossaryTerm:email",
      "parentNodes": {
        "count": 1,
        "nodes": [
          {
            "urn": "urn:li:glossaryNode:data-type",
            "type": "GLOSSARY_NODE",
            "parentNodes": {
              "count": 0,
              "nodes": []
            }
          }
        ]
      }
    }
  },
  "extensions": {}
}
b
You can use the relationships field of the GlossaryTerm
Let me provide an example
Copy code
query getGlossaryNode($urn: String!) {
    glossaryNode(urn: $urn) {
        urn
        children: relationships(
            input: {
                types: ["IsPartOf"]
                direction: INCOMING
                start: 0
                count: 10000
            }
        ) {
            total
            relationships {
                direction
                entity {
                    type
                    urn
                    ... on GlossaryNode {
                        ... glossary node fields
                    }
                    ... on GlossaryTerm {
                        ... glossary term fields
                    }
                }
            }
        }
    }
}
So basically the relationships field allows you to traverse the graph down to the children. Ideally, we'd have a stronger GraphQL field for this one. Let me add that to our backlog
a
Thank you @big-carpet-38439!