[英]How to fetch children of node via webroot path in Gentics Mesh?
我有一個父節點的webroot路徑,並希望返回此節點的子節點。 例如,使用https://demo.getmesh.io/api/v1/demo/webroot/images/只會產生節點本身。
不幸的是,只有webroot這樣做是不可能的。 但是,還有其他方法可以實現它:
例如,使用此查詢使用GraphQL-Enpoint :
query childrenByWebroot($path: String) { node(path: $path) { uuid children { elements { uuid } } } }
這將只加載子項和父項的所有UUID。 有關更多功能,請查看GraphQL文檔以獲取更多信息。
首先從webroot加載節點,然后通過Children-Endpoint加載子/api/v1/<project>/nodes/<uuid>/children
: /api/v1/<project>/nodes/<uuid>/children
搜索將webroot-element作為父級的節點。 這使您可以在需要時更清楚地過濾內容:
{ "query": { "bool": { "must": [ { "term": { "parentNode.uuid": "<uuid>" }, // ... Other checks } ] } } }
目前無法使用單個請求通過REST加載節點的子節點。 但是,您可以加載路徑的節點。 使用該節點的uuid並通過/ api / v1 /:projectName / nodes /:nodeUuid / children加載子節點
然而,更優雅的方法是使用以下graphql查詢。 我強烈推薦這個選項,因為它在處理大型數據集時更有效。
背景:計算totalCount
/ totalPage
大小是昂貴的,您可以通過使用hasPreviousPage
和hasNextPage
來避免這種hasNextPage
。
您可以使用以下graphql查詢 :
query ($path: String) {
node(path: $path) {
children(perPage: 5) {
hasNextPage
hasPreviousPage
currentPage
elements {
uuid
fields {
... on vehicleImage {
name
}
}
}
}
}
}
查詢變量:
{
"path": "/images"
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.