I have a webroot path of a parent node and would like to return the children of this node. Using https://demo.getmesh.io/api/v1/demo/webroot/images/ for example just yields the node itself.
Unfortunately it's not possible to do so with just the webroot. However, there're other ways to accomplish it:
Use the GraphQL-Enpoint by using this query for example:
query childrenByWebroot($path: String) {
node(path: $path) {
uuid
children {
elements {
uuid
}
}
}
}
This will just load all UUIDs of the children and the parent. For more functionality, check the Docs of GraphQL for more information.
Load the Node from the webroot first and and then load the children via the Children-Endpoint: /api/v1/<project>/nodes/<uuid>/children
Search for Nodes which have the webroot-element as parent. This allows you to filter the content more clearly if it is required:
{
"query": {
"bool": {
"must": [
{
"term": {
"parentNode.uuid": "<uuid>"
},
// ... Other checks
}
]
}
}
}
There is currently no way to load the children of a node via REST using a single request. You can however load the node of the path. Use the uuid of that node and load the children via /api/v1/:projectName/nodes/:nodeUuid/children
A much more elegant approach however would be to use the following graphql query. I highly recommend this option since it is more efficient when handling large datasets.
Background: Computing the totalCount
/ totalPage
size is costly and you can avoid this by using hasPreviousPage
and hasNextPage
.
You can use the following graphql query:
query ($path: String) {
node(path: $path) {
children(perPage: 5) {
hasNextPage
hasPreviousPage
currentPage
elements {
uuid
fields {
... on vehicleImage {
name
}
}
}
}
}
}
Query variables:
{
"path": "/images"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With