/
search_traversal.json
54 lines (54 loc) · 4.88 KB
/
search_traversal.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{
"@components": {
"actions": {
"@id": "http://localhost:8080/Plone/docs/search_traversal/@actions"
},
"breadcrumbs": {
"@id": "http://localhost:8080/Plone/docs/search_traversal/@breadcrumbs"
},
"navigation": {
"@id": "http://localhost:8080/Plone/docs/search_traversal/@navigation"
},
"workflow": {
"@id": "http://localhost:8080/Plone/docs/search_traversal/@workflow"
}
},
"@id": "http://localhost:8080/Plone/docs/search_traversal",
"@type": "Document",
"UID": "7ec8087c2b4e44acb4d96495db037415",
"allow_discussion": false,
"changeNote": "",
"contributors": [],
"created": "2018-07-11T08:03:57+00:00",
"creators": [
"admin"
],
"description": "",
"effective": null,
"exclude_from_nav": false,
"expires": null,
"id": "search_traversal",
"is_folderish": false,
"language": "",
"layout": "document_view",
"modified": "2018-07-12T12:29:30+00:00",
"parent": {
"@id": "http://localhost:8080/Plone/docs",
"@type": "Folder",
"description": "Plugin documentation",
"review_state": "published",
"title": "Docs"
},
"relatedItems": [],
"review_state": "published",
"rights": "",
"subjects": [],
"table_of_contents": null,
"text": {
"content-type": "text/html",
"data": "<p>In the <a href=\"https://github.com/plone/plone.restapi\">plone.restapi</a>, the <code>@search</code> endpoint when fetched without any query returns the full list of content objects. This is used to pull the whole content tree and create nodes with tree hierarchy.</p>\n<p>The procedure followed for this:</p>\n<ol>\n<li>Use the <code>@search</code> endpoint to get a flat list of all content objects.\nFor instance, <code>https://plonedemo.kitconcept.com/en/@search</code> gives the response:</li>\n</ol>\n<pre><code class=\"lang-json\">{\n \"@id\": \"https://plonedemo.kitconcept.com/en/@search\",\n \"items\": [\n {\n \"@id\": \"https://plonedemo.kitconcept.com/en\",\n \"@type\": \"LRF\",\n \"description\": \"\",\n \"review_state\": \"published\",\n \"title\": \"English\"\n },\n {\n \"@id\": \"https://plonedemo.kitconcept.com/en/frontpage\",\n \"@type\": \"Document\",\n \"description\": \"The ultimate Open Source Enterprise CMS\",\n \"review_state\": \"published\",\n \"title\": \"Welcome to Plone 5\"\n },\n {\n \"@id\": \"https://plonedemo.kitconcept.com/en/demo/a-page\",\n \"@type\": \"Document\",\n \"description\": \"Aenean dictum auctor elit, in volutpat ipsum venenatis at. Quisque lobortis augue et enim venenatis interdum. In egestas, est at condimentum ultrices, tortor enim malesuada nulla; vel sagittis nullam.\",\n \"review_state\": \"published\",\n \"title\": \"A Page\"\n },\n ...\n</code></pre>\n<p>The <code>items</code> is an array of all the content objects.</p>\n<ol start=\"2\">\n<li>Using this flat list, iterate through the <code>@id</code> attributes making individual requests for each content object to get full data.\nFrom the previous request, we extract the <code>@id</code>s forming a list of URLs for each content object:</li>\n</ol>\n<pre><code>https://plonedemo.kitconcept.com/en\nhttps://plonedemo.kitconcept.com/en/frontpage\nhttps://plonedemo.kitconcept.com/en/demo/a-page\n...\n</code></pre><p>Each request will fetch the required data of the content object:</p>\n<pre><code class=\"lang-json\">// https://plonedemo.kitconcept.com/en/demo/a-page\n{\n \"@components\": {\n \"breadcrumbs\": {\n \"@id\": \"https://plonedemo.kitconcept.com/en/demo/a-page/@breadcrumbs\"\n },\n \"navigation\": {\n \"@id\": \"https://plonedemo.kitconcept.com/en/demo/a-page/@navigation\"\n },\n \"workflow\": {\n \"@id\": \"https://plonedemo.kitconcept.com/en/demo/a-page/@workflow\"\n }\n },\n \"@id\": \"https://plonedemo.kitconcept.com/en/demo/a-page\",\n \"@type\": \"Document\",\n \"UID\": \"eb023ac4d6cd4446ae692cdfd5058e91\",\n \"allow_discussion\": null,\n \"changeNote\": \"\",\n \"contributors\": [],\n \"created\": \"2015-07-31T15:42:54+02:00\",\n ...\n</code></pre>\n<ol start=\"3\">\n<li><p>Spread this data to nodes (making them available for GraphQL requests in Gatsby)</p>\n</li>\n<li><p>For hierarchy, <em>Gatsby at node level uses a 'parent' and 'children' property</em>. From the data retrieved parent will be assigned from <code>parent</code> attribute of the object directly, while children is an array of <code>@id</code> which is obtained by traversal of <code>items</code> attribute of a content object. This is possible considering that <code>node.id</code> is the <code>@id</code> attribute.</p>\n</li>\n</ol>",
"encoding": "utf-8"
},
"title": "Traversal using @search endpoint",
"version": "current"
}