Custom DQL does work with @recurse . I believe the reason the query didn’t work is because you have func: eq(title, $title) instead of func: eq(Node.title, $title) inside the custom DQL query.
If you want to get subgraph starting from a node, you could also use the generated queryNode query providing it with the right filter.
As you can see it is not the same data. I would like to get the data, so if you can guide me how to do it using queryNode or fix the current DQL custom query that would be greatly appreciated
What version of Dgraph are you using. I tried reproducing this with master version. But, the query seemed to work fine.
If you want to get subtree of a graph, starting with a node, you could also use the GraphQL query directly. A custom DQL query for this purpose is an overkill.
query{
queryNode(filter:{title:{eq:"today"}}){
title
children{
title
children{
title
}
}
}
}
I am not sure if it is overkill, the query you have provided seems to only return three levels deep, but what I want is to return the subtree no matter what depth there is, I don’t think I can do that with just Graphql
huh. that is a bummer Now I understand why you think it is an overkill
So as it stands there is no way to get an unknown level deep tree with just Graphql I would have to run a query using DQL.
Do you know if Slash Graphql exposes a way to run DQL queries directly? (not using Graphql)
It is possible. You could use the /query endpoint. You may read more details here . Depending on your use case, you could use http, grpc or any other Dgraph client.
Sorry for resurrecting an old thread, but couldn’t you perform your query, let’s say it goes 5 levels deep. Let’s also call the nodes that exist at the 5th level ‘leaf’ nodes. If you return the IDs of the nodes, and also a boolean that tells you whether a given node has child nodes or not, for any leaf nodes that do have children, you submit another query. Of course, depending on the data this could generate a lot of queries and you might end up needing logic to mitigate that problem.
I can imagine using datascript - npm (an in-memory clientside database used by https://roamresearch.com and others) to cache complex nested data, because it probably goes beyond the scope of a simple query cache like Apollo’s for example. EDIT: Then you avoid having to re-run these queries, you gradually build up the client-side data (and it’s even queriable with datascript).