{"action":"created","comment":{"url":"https://api.github.com/repos/plone/training/pulls/comments/228712715","pull_request_review_id":169054616,"id":228712715,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyODcxMjcxNQ==","diff_hunk":"@@ -0,0 +1,142 @@\n+Fetching Data Using Plone REST.API\n+==================================\n+\n+Now that we have an idea of how to create nodes, we can move on to retrieving data from a Plone site and creating nodes with that data.\n+\n+All the data from a Plone site is available in the JSON format using the `plone.restapi <https://plonerestapi.readthedocs.io/en/latest/introduction.html>`_.\n+\n+We will be working a lot with this API while working on the Gatsby source-plugin, so it is recommended that you have an API browser to explore the API.\n+Install `Postman <https://www.getpostman.com/>`_ and do go through the quick guide to working with plone.restapi:\n+\n+https://plonerestapi.readthedocs.io/en/latest/exploring.html#exploring-api-postman-onboarding\n+\n+.. note::\n+\n+  We will use the same endpoints for loading the site in a browser, but set the header ``Accept: application/json``.\n+  This header tells the endpoint to return JSON data in the response for us to process.\n+\n+Exploring The Plone REST.API\n+----------------------------\n+\n+We will use https://plonedemo.kitconcept.com/en as our source Plone site, since it's already been configured with the plone.restapi and is all ready for our usage.\n+\n+Let us start with the root itself.\n+Send a GET request to https://plonedemo.kitconcept.com/en.\n+This returns the JSON data for the root of the Plone site.\n+\n+.. code-block:: json\n+\n+  {\n+    \"@components\": {\n+        \"breadcrumbs\": {\n+            \"@id\": \"https://plonedemo.kitconcept.com/en/frontpage/@breadcrumbs\"\n+        },\n+        \"navigation\": {\n+            \"@id\": \"https://plonedemo.kitconcept.com/en/frontpage/@navigation\"\n+        },\n+        \"workflow\": {\n+            \"@id\": \"https://plonedemo.kitconcept.com/en/frontpage/@workflow\"\n+        }\n+    },\n+    \"@id\": \"https://plonedemo.kitconcept.com/en/frontpage\",\n+    \"@type\": \"Document\",\n+    \"UID\": \"5938b3c2c0e147b18fbf20d32842eb06\",\n+    \"allow_discussion\": null,\n+    \"changeNote\": \"\",\n+    \"contributors\": [],\n+    \"created\": \"2018-10-13T13:25:31+00:00\",\n+    \"creators\": [\n+        \"admin\"\n+    ],\n+   ...\n+\n+Let us explore the ``items`` array from the response and click on https://plonedemo.kitconcept.com/en/frontpage.\n+We see that it gives a similar response as we got for the root.\n+This way all the content objects have equivalent JSON data which our plugin can process and use to create nodes.\n+\n+\n+Exercise\n+++++++++\n+\n+Create a node for the Plone document at https://plonedemo.kitconcept.com/en/demo/a-page.\n+Test the node created from the retrieved data by displaying some data in the ``index`` or any other page.\n+\n+Hints: Use Postman to check the data from the endpoint and process accordingly. \n+The Axios library can be used for handling HTTP requests.\n+\n+.. note::\n+\n+    Minor errors may arise when Gatsby node specific fields are overwritten by spreading the Plone object data.\n+    For now, they can be fixed by defaulting them to the node field data: `node.parent` is an empty string and `node.children` an empty array.\n+    \n+\n+..  admonition:: Solution\n+    :class: toggle\n+\n+    .. code-block:: javascript\n+\n+    exports.sourceNodes = async ({ actions }) => {\n+      const { createNode } = actions;\n+\n+      const { data } = await axios.get('https://plonedemo.kitconcept.com/en/demo/a-page', {","path":"gatsby/plonerestapi.rst","position":81,"original_position":81,"commit_id":"74561b90bbc9fd493e4fad9e7200aa6334edbcf2","original_commit_id":"74561b90bbc9fd493e4fad9e7200aa6334edbcf2","user":{"login":"cekk","id":1402078,"node_id":"MDQ6VXNlcjE0MDIwNzg=","avatar_url":"https://avatars1.githubusercontent.com/u/1402078?v=4","gravatar_id":"","url":"https://api.github.com/users/cekk","html_url":"https://github.com/cekk","followers_url":"https://api.github.com/users/cekk/followers","following_url":"https://api.github.com/users/cekk/following{/other_user}","gists_url":"https://api.github.com/users/cekk/gists{/gist_id}","starred_url":"https://api.github.com/users/cekk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cekk/subscriptions","organizations_url":"https://api.github.com/users/cekk/orgs","repos_url":"https://api.github.com/users/cekk/repos","events_url":"https://api.github.com/users/cekk/events{/privacy}","received_events_url":"https://api.github.com/users/cekk/received_events","type":"User","site_admin":false},"body":"i see some problems for a newbie.\r\n\r\nYou mentioned axios in the description: i would give a link to npm or github, so they can directly access to its documentation.\r\n\r\nYou are using async method here for the first time. You should probably explain what it is and how it works (python developers are not used to async methods)\r\n\r\nCould be a good idea to provide a link to official gatsby documentation about sourceNodes?","created_at":"2018-10-27T13:17:39Z","updated_at":"2018-10-27T13:47:01Z","html_url":"https://github.com/plone/training/pull/342#discussion_r228712715","pull_request_url":"https://api.github.com/repos/plone/training/pulls/342","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/plone/training/pulls/comments/228712715"},"html":{"href":"https://github.com/plone/training/pull/342#discussion_r228712715"},"pull_request":{"href":"https://api.github.com/repos/plone/training/pulls/342"}}},"pull_request":{"url":"https://api.github.com/repos/plone/training/pulls/342","id":225606799,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI1NjA2Nzk5","html_url":"https://github.com/plone/training/pull/342","diff_url":"https://github.com/plone/training/pull/342.diff","patch_url":"https://github.com/plone/training/pull/342.patch","issue_url":"https://api.github.com/repos/plone/training/issues/342","number":342,"state":"open","locked":false,"title":"Gatsby Training: building the source-plone plugin","user":{"login":"ajayns","id":20743219,"node_id":"MDQ6VXNlcjIwNzQzMjE5","avatar_url":"https://avatars0.githubusercontent.com/u/20743219?v=4","gravatar_id":"","url":"https://api.github.com/users/ajayns","html_url":"https://github.com/ajayns","followers_url":"https://api.github.com/users/ajayns/followers","following_url":"https://api.github.com/users/ajayns/following{/other_user}","gists_url":"https://api.github.com/users/ajayns/gists{/gist_id}","starred_url":"https://api.github.com/users/ajayns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajayns/subscriptions","organizations_url":"https://api.github.com/users/ajayns/orgs","repos_url":"https://api.github.com/users/ajayns/repos","events_url":"https://api.github.com/users/ajayns/events{/privacy}","received_events_url":"https://api.github.com/users/ajayns/received_events","type":"User","site_admin":false},"body":"@cekk Added docs for the building plugin part. Working on the using the existing plugin with starter part.","created_at":"2018-10-25T02:42:24Z","updated_at":"2018-10-27T13:47:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5855b67f0bca059b87e085894ace8a06c12985c7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/plone/training/pulls/342/commits","review_comments_url":"https://api.github.com/repos/plone/training/pulls/342/comments","review_comment_url":"https://api.github.com/repos/plone/training/pulls/comments{/number}","comments_url":"https://api.github.com/repos/plone/training/issues/342/comments","statuses_url":"https://api.github.com/repos/plone/training/statuses/74561b90bbc9fd493e4fad9e7200aa6334edbcf2","head":{"label":"plone:gatsby-training-plugin","ref":"gatsby-training-plugin","sha":"74561b90bbc9fd493e4fad9e7200aa6334edbcf2","user":{"login":"plone","id":72034,"node_id":"MDEyOk9yZ2FuaXphdGlvbjcyMDM0","avatar_url":"https://avatars0.githubusercontent.com/u/72034?v=4","gravatar_id":"","url":"https://api.github.com/users/plone","html_url":"https://github.com/plone","followers_url":"https://api.github.com/users/plone/followers","following_url":"https://api.github.com/users/plone/following{/other_user}","gists_url":"https://api.github.com/users/plone/gists{/gist_id}","starred_url":"https://api.github.com/users/plone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plone/subscriptions","organizations_url":"https://api.github.com/users/plone/orgs","repos_url":"https://api.github.com/users/plone/repos","events_url":"https://api.github.com/users/plone/events{/privacy}","received_events_url":"https://api.github.com/users/plone/received_events","type":"Organization","site_admin":false},"repo":{"id":21737946,"node_id":"MDEwOlJlcG9zaXRvcnkyMTczNzk0Ng==","name":"training","full_name":"plone/training","private":false,"owner":{"login":"plone","id":72034,"node_id":"MDEyOk9yZ2FuaXphdGlvbjcyMDM0","avatar_url":"https://avatars0.githubusercontent.com/u/72034?v=4","gravatar_id":"","url":"https://api.github.com/users/plone","html_url":"https://github.com/plone","followers_url":"https://api.github.com/users/plone/followers","following_url":"https://api.github.com/users/plone/following{/other_user}","gists_url":"https://api.github.com/users/plone/gists{/gist_id}","starred_url":"https://api.github.com/users/plone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plone/subscriptions","organizations_url":"https://api.github.com/users/plone/orgs","repos_url":"https://api.github.com/users/plone/repos","events_url":"https://api.github.com/users/plone/events{/privacy}","received_events_url":"https://api.github.com/users/plone/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/plone/training","description":"A training for future Plone developers","fork":false,"url":"https://api.github.com/repos/plone/training","forks_url":"https://api.github.com/repos/plone/training/forks","keys_url":"https://api.github.com/repos/plone/training/keys{/key_id}","collaborators_url":"https://api.github.com/repos/plone/training/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/plone/training/teams","hooks_url":"https://api.github.com/repos/plone/training/hooks","issue_events_url":"https://api.github.com/repos/plone/training/issues/events{/number}","events_url":"https://api.github.com/repos/plone/training/events","assignees_url":"https://api.github.com/repos/plone/training/assignees{/user}","branches_url":"https://api.github.com/repos/plone/training/branches{/branch}","tags_url":"https://api.github.com/repos/plone/training/tags","blobs_url":"https://api.github.com/repos/plone/training/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/plone/training/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/plone/training/git/refs{/sha}","trees_url":"https://api.github.com/repos/plone/training/git/trees{/sha}","statuses_url":"https://api.github.com/repos/plone/training/statuses/{sha}","languages_url":"https://api.github.com/repos/plone/training/languages","stargazers_url":"https://api.github.com/repos/plone/training/stargazers","contributors_url":"https://api.github.com/repos/plone/training/contributors","subscribers_url":"https://api.github.com/repos/plone/training/subscribers","subscription_url":"https://api.github.com/repos/plone/training/subscription","commits_url":"https://api.github.com/repos/plone/training/commits{/sha}","git_commits_url":"https://api.github.com/repos/plone/training/git/commits{/sha}","comments_url":"https://api.github.com/repos/plone/training/comments{/number}","issue_comment_url":"https://api.github.com/repos/plone/training/issues/comments{/number}","contents_url":"https://api.github.com/repos/plone/training/contents/{+path}","compare_url":"https://api.github.com/repos/plone/training/compare/{base}...{head}","merges_url":"https://api.github.com/repos/plone/training/merges","archive_url":"https://api.github.com/repos/plone/training/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/plone/training/downloads","issues_url":"https://api.github.com/repos/plone/training/issues{/number}","pulls_url":"https://api.github.com/repos/plone/training/pulls{/number}","milestones_url":"https://api.github.com/repos/plone/training/milestones{/number}","notifications_url":"https://api.github.com/repos/plone/training/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/plone/training/labels{/name}","releases_url":"https://api.github.com/repos/plone/training/releases{/id}","deployments_url":"https://api.github.com/repos/plone/training/deployments","created_at":"2014-07-11T13:56:42Z","updated_at":"2018-10-26T10:04:29Z","pushed_at":"2018-10-27T10:43:43Z","git_url":"git://github.com/plone/training.git","ssh_url":"git@github.com:plone/training.git","clone_url":"https://github.com/plone/training.git","svn_url":"https://github.com/plone/training","homepage":"https://training.plone.org/","size":12519,"stargazers_count":24,"watchers_count":24,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":54,"mirror_url":null,"archived":false,"open_issues_count":73,"license":{"key":"cc-by-4.0","name":"Creative Commons Attribution 4.0 International","spdx_id":"CC-BY-4.0","url":"https://api.github.com/licenses/cc-by-4.0","node_id":"MDc6TGljZW5zZTI1"},"forks":54,"open_issues":73,"watchers":24,"default_branch":"master"}},"base":{"label":"plone:gatsby-training","ref":"gatsby-training","sha":"c20e1f40dc83883d298452e363a62fa22d1f1066","user":{"login":"plone","id":72034,"node_id":"MDEyOk9yZ2FuaXphdGlvbjcyMDM0","avatar_url":"https://avatars0.githubusercontent.com/u/72034?v=4","gravatar_id":"","url":"https://api.github.com/users/plone","html_url":"https://github.com/plone","followers_url":"https://api.github.com/users/plone/followers","following_url":"https://api.github.com/users/plone/following{/other_user}","gists_url":"https://api.github.com/users/plone/gists{/gist_id}","starred_url":"https://api.github.com/users/plone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plone/subscriptions","organizations_url":"https://api.github.com/users/plone/orgs","repos_url":"https://api.github.com/users/plone/repos","events_url":"https://api.github.com/users/plone/events{/privacy}","received_events_url":"https://api.github.com/users/plone/received_events","type":"Organization","site_admin":false},"repo":{"id":21737946,"node_id":"MDEwOlJlcG9zaXRvcnkyMTczNzk0Ng==","name":"training","full_name":"plone/training","private":false,"owner":{"login":"plone","id":72034,"node_id":"MDEyOk9yZ2FuaXphdGlvbjcyMDM0","avatar_url":"https://avatars0.githubusercontent.com/u/72034?v=4","gravatar_id":"","url":"https://api.github.com/users/plone","html_url":"https://github.com/plone","followers_url":"https://api.github.com/users/plone/followers","following_url":"https://api.github.com/users/plone/following{/other_user}","gists_url":"https://api.github.com/users/plone/gists{/gist_id}","starred_url":"https://api.github.com/users/plone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plone/subscriptions","organizations_url":"https://api.github.com/users/plone/orgs","repos_url":"https://api.github.com/users/plone/repos","events_url":"https://api.github.com/users/plone/events{/privacy}","received_events_url":"https://api.github.com/users/plone/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/plone/training","description":"A training for future Plone developers","fork":false,"url":"https://api.github.com/repos/plone/training","forks_url":"https://api.github.com/repos/plone/training/forks","keys_url":"https://api.github.com/repos/plone/training/keys{/key_id}","collaborators_url":"https://api.github.com/repos/plone/training/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/plone/training/teams","hooks_url":"https://api.github.com/repos/plone/training/hooks","issue_events_url":"https://api.github.com/repos/plone/training/issues/events{/number}","events_url":"https://api.github.com/repos/plone/training/events","assignees_url":"https://api.github.com/repos/plone/training/assignees{/user}","branches_url":"https://api.github.com/repos/plone/training/branches{/branch}","tags_url":"https://api.github.com/repos/plone/training/tags","blobs_url":"https://api.github.com/repos/plone/training/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/plone/training/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/plone/training/git/refs{/sha}","trees_url":"https://api.github.com/repos/plone/training/git/trees{/sha}","statuses_url":"https://api.github.com/repos/plone/training/statuses/{sha}","languages_url":"https://api.github.com/repos/plone/training/languages","stargazers_url":"https://api.github.com/repos/plone/training/stargazers","contributors_url":"https://api.github.com/repos/plone/training/contributors","subscribers_url":"https://api.github.com/repos/plone/training/subscribers","subscription_url":"https://api.github.com/repos/plone/training/subscription","commits_url":"https://api.github.com/repos/plone/training/commits{/sha}","git_commits_url":"https://api.github.com/repos/plone/training/git/commits{/sha}","comments_url":"https://api.github.com/repos/plone/training/comments{/number}","issue_comment_url":"https://api.github.com/repos/plone/training/issues/comments{/number}","contents_url":"https://api.github.com/repos/plone/training/contents/{+path}","compare_url":"https://api.github.com/repos/plone/training/compare/{base}...{head}","merges_url":"https://api.github.com/repos/plone/training/merges","archive_url":"https://api.github.com/repos/plone/training/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/plone/training/downloads","issues_url":"https://api.github.com/repos/plone/training/issues{/number}","pulls_url":"https://api.github.com/repos/plone/training/pulls{/number}","milestones_url":"https://api.github.com/repos/plone/training/milestones{/number}","notifications_url":"https://api.github.com/repos/plone/training/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/plone/training/labels{/name}","releases_url":"https://api.github.com/repos/plone/training/releases{/id}","deployments_url":"https://api.github.com/repos/plone/training/deployments","created_at":"2014-07-11T13:56:42Z","updated_at":"2018-10-26T10:04:29Z","pushed_at":"2018-10-27T10:43:43Z","git_url":"git://github.com/plone/training.git","ssh_url":"git@github.com:plone/training.git","clone_url":"https://github.com/plone/training.git","svn_url":"https://github.com/plone/training","homepage":"https://training.plone.org/","size":12519,"stargazers_count":24,"watchers_count":24,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":54,"mirror_url":null,"archived":false,"open_issues_count":73,"license":{"key":"cc-by-4.0","name":"Creative Commons Attribution 4.0 International","spdx_id":"CC-BY-4.0","url":"https://api.github.com/licenses/cc-by-4.0","node_id":"MDc6TGljZW5zZTI1"},"forks":54,"open_issues":73,"watchers":24,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/plone/training/pulls/342"},"html":{"href":"https://github.com/plone/training/pull/342"},"issue":{"href":"https://api.github.com/repos/plone/training/issues/342"},"comments":{"href":"https://api.github.com/repos/plone/training/issues/342/comments"},"review_comments":{"href":"https://api.github.com/repos/plone/training/pulls/342/comments"},"review_comment":{"href":"https://api.github.com/repos/plone/training/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/plone/training/pulls/342/commits"},"statuses":{"href":"https://api.github.com/repos/plone/training/statuses/74561b90bbc9fd493e4fad9e7200aa6334edbcf2"}},"author_association":"NONE"}}
{"actor":{"display_login":"cekk"}}