{"id":1585,"date":"2017-07-05T14:45:44","date_gmt":"2017-07-05T06:45:44","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=1585"},"modified":"2017-07-05T14:45:44","modified_gmt":"2017-07-05T06:45:44","slug":"github-graphql-%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=1585","title":{"rendered":"Github GraphQL \u4ecb\u7ecd"},"content":{"rendered":"<p>\n\t\u73b0\u5728\u6211\u8d8a\u6765\u8d8a\u610f\u8bc6\u5230\u82f1\u8bed\u7684\u91cd\u8981\u6027\u4e86\u3002\u5f88\u591a\u77e5\u8bc6\u70b9\u7f3a\u5c11\u4e2d\u6587\u8d44\u6599\uff0c\u800c\u82f1\u6587\u5374\u6709\u5f88\u591a\u535a\u6587\u3002\u5e0c\u671b\u4eba\u5de5\u667a\u80fd\u5728\u8fd9\u65b9\u9762\u80fd\u5e2e\u5230\u6211\u3002\n<\/p>\n<p>\n\tGitHub \u5ba3\u5e03\u5f00\u653e\u4e86\u4e00\u5957\u4f7f\u7528 GraphQL \u5f00\u53d1\u7684\u516c\u5171 API\u3002\n<\/p>\n<p>\n\tGitHub \u7684 REST API \u5df2\u7ecf\u975e\u5e38\u5b8c\u5584\uff0c\u8bbe\u8ba1\u5f97\u5f88\u4f18\u79c0\uff0c\u5f88\u591a\u516c\u53f8\u5f00\u53d1\u81ea\u5df1\u7684 REST API \u65f6\u90fd\u4f1a\u53c2\u8003 GitHub\uff0c\u4e5f\u6709\u5f88\u591a\u7231\u597d\u8005\u5199\u4e86\u975e\u5e38\u4e30\u5bcc\u7684\u6559\u7a0b\u3002\n<\/p>\n<p>\n\tGraphQL \u7684\u6838\u5fc3\u662f\u4e00\u5957\u6570\u636e\u67e5\u8be2\u8bed\u8a00\u7684\u89c4\u8303\uff0c\u662f Facebook \u57282012\u5e74\u5f00\u53d1\u7684\uff0c2015\u5e74\u5f00\u6e90\uff0cFacebook \u5185\u90e8\u5df2\u7ecf\u5e7f\u6cdb\u5e94\u7528\uff0c\u7528\u4e8e\u66ff\u4ee3 REST\u3002\n<\/p>\n<p>\n\tGitHub \u4e3a\u4ec0\u4e48\u9009\u62e9 GraphQL\uff1f\u8fd9\u662f\u5f88\u591a\u7528\u6237\u5173\u5fc3\u7684\u95ee\u9898\uff0cGithub \u5bf9\u6b64\u505a\u4e86\u89e3\u91ca\u3002\n<\/p>\n<h2>\n\tREST API<br \/>\n<\/h2>\n<p>\n\t\u9996\u8981\u95ee\u9898\u5c31\u662f\u6269\u5c55\u6027\u65b9\u9762\uff0c\u968f\u7740 API \u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u4f1a\u53d8\u5f97\u8d8a\u6765\u8d8a\u81c3\u80bf\n<\/p>\n<p>\n\tREST API \u7684\u65b9\u5f0f\u662f\uff1aserver\u5b9a\u4e49\u4e00\u7cfb\u5217\u7684\u63a5\u53e3\uff0cclient\u8c03\u7528\u81ea\u5df1\u9700\u8981\u7684\u63a5\u53e3\uff0c\u83b7\u53d6\u76ee\u6807\u6570\u636e\u8fdb\u884c\u6574\u5408\n<\/p>\n<p>\n\t\u4f8b\u5982\u7528\u6237\u63a5\u53e3\uff0c\u521a\u5f00\u59cb\u65f6\uff0c\u8fd4\u56de\u7684\u4fe1\u606f\u4f1a\u6bd4\u8f83\u5c11\uff0c\u4f8b\u5982\u53ea\u6709 id,name\n<\/p>\n<p>\n\t\u540e\u6765\u7528\u6237\u7684\u4fe1\u606f\u589e\u52a0\u4e86\uff0c\u5c31\u5728\u7528\u6237\u63a5\u53e3\u4e2d\u8fd4\u56de\u66f4\u591a\u7684\u4fe1\u606f\uff0c\u4f8b\u5982 id,name,age,city,addr,email,headimage,nick\n<\/p>\n<p>\n\t\u4f46\u53ef\u80fd\u5f88\u591aclient\u53ea\u662f\u60f3\u83b7\u53d6\u5176\u4e2d\u5c11\u90e8\u5206\u4fe1\u606f\uff0c\u5982 name,headimage\uff0c\u5374\u5fc5\u987b\u5f97\u5230\u6240\u6709\u7684\u7528\u6237\u4fe1\u606f\uff0c\u7136\u540e\u4ece\u4e2d\u63d0\u53d6\u81ea\u5df1\u60f3\u8981\u7684\n<\/p>\n<p>\n\t\u8fd9\u4e2a\u60c5\u51b5\u4f1a\u589e\u52a0\u7f51\u7edc\u4f20\u8f93\u91cf\uff0c\u5e76\u4e14\u4e0d\u4fbf\u4e8eclient\u5904\u7406\u6570\u636e\n<\/p>\n<p>\n\t\u8fd8\u6709\u4e00\u4e2a\u4e0d\u65b9\u4fbf\u7684\u5730\u65b9\uff0c\u4f8b\u5982client\u5728\u67d0\u4e2a\u9700\u6c42\u4e2d\uff0c\u53ef\u80fd\u9700\u8981\u8c03\u7528\u591a\u4e2a\u72ec\u7acb\u7684 API \u624d\u80fd\u83b7\u53d6\u5230\u8db3\u591f\u7684\u6570\u636e\n<\/p>\n<p>\n\t\u4f8b\u5982client\u8981\u663e\u793a\u4e00\u7bc7\u6587\u7ae0\u7684\u5185\u5bb9\uff0c\u540c\u65f6\u8981\u663e\u793a\u8bc4\u8bba\u3001\u4f5c\u8005\u4fe1\u606f\uff0c\u90a3\u4e48\u5c31\u53ef\u80fd\u9700\u8981\u8c03\u7528\u6587\u7ae0\u63a5\u53e3\u3001\u8bc4\u8bba\u63a5\u53e3\u3001\u7528\u6237\u63a5\u53e3\n<\/p>\n<p>\n\t\u8fd9\u79cd\u65b9\u5f0f\u975e\u5e38\u4e0d\u7075\u6d3b\n<\/p>\n<p>\n\tGitHub \u8fd8\u9047\u5230\u5176\u4ed6\u4e00\u4e9b REST API \u4e0d\u597d\u5904\u7406\u7684\u95ee\u9898\uff0c\u4f8b\u5982\n<\/p>\n<p>\n\t\u60f3\u8981\u786e\u4fddclient\u63d0\u4f9b\u7684\u53c2\u6570\u7684\u7c7b\u578b\u5b89\u5168\uff1b\u60f3\u8981\u4ece\u4ee3\u7801\u751f\u6210\u6587\u6863\uff1b\u60f3\u8981\u8bc6\u522b\u6bcf\u4e2a\u7aef\u70b9\u7684OAuth\u8bf7\u6c42\u8303\u56f4\u7b49\u3002\n<\/p>\n<h2>\n\tGraphQL<br \/>\n<\/h2>\n<p>\n\tGraphQL \u7b80\u5355\u6765\u8bf4\u5c31\u662f\uff1a\u53d6\u54ea\u4e9b\u6570\u636e\u662f\u7531client\u6765\u51b3\u5b9a\n<\/p>\n<p>\n\tREST \u4e2d\uff0c\u7ed9\u54ea\u4e9b\u6570\u636e\u662fserver\u51b3\u5b9a\u7684\uff0cclient\u53ea\u80fd\u4ece\u4e2d\u6311\u9009\uff0c\u5982\u679cA\u63a5\u53e3\u4e2d\u7684\u6570\u636e\u4e0d\u591f\uff0c\u518d\u8bf7\u6c42B\u63a5\u53e3\uff0c\u7136\u540e\u4ece\u4ed6\u4eec\u8fd4\u56de\u7684\u6570\u636e\u4e2d\u6311\u51fa\u81ea\u5df1\u9700\u8981\u7684\n<\/p>\n<p>\n\tGraphQL \u4e2d\uff0cclient \u76f4\u63a5\u5bf9 server\u8bf4\u60f3\u8981\u4ec0\u4e48\u6570\u636e\uff0cserver\u8d1f\u8d23\u7cbe\u786e\u7684\u8fd4\u56de\u76ee\u6807\u6570\u636e\n<\/p>\n<p>\n\t\u4f8b\u5982\uff0c\u4f60\u60f3\u8981\u83b7\u53d6\u7528\u6237\u7684\u51e0\u4e2a\u5c5e\u6027\u4fe1\u606f\uff0c\u4f60\u7684 GraphQL \u8bf7\u6c42\u5c31\u662f\u8fd9\u6837\u7684\n<\/p>\n<pre class=\"brush:plain;\">\r\n{\r\n viewer {\r\n   login\r\n   bio\r\n   location\r\n   isBountyHunter\r\n }\r\n}<\/pre>\n<p>\n\t\u8fd4\u56de\u7684\u54cd\u5e94\u4fe1\u606f\u5982\u4e0b\n<\/p>\n<pre class=\"brush:plain;\">\r\n{\r\n &quot;data&quot;: {\r\n   &quot;viewer&quot;: {\r\n     &quot;login&quot;: &quot;octocat&quot;,\r\n     &quot;bio&quot;: &quot;I&#39;ve been around the world, from London to the Bay.&quot;,\r\n     &quot;location&quot;: &quot;San Francisco, CA&quot;,\r\n     &quot;isBountyHunter&quot;: true\r\n   }\r\n }\r\n}<\/pre>\n<p>\n\t\u518d\u770b\u4e00\u4e2a\u66f4\u590d\u6742\u7684\u4f8b\u5b50\uff0c\u4f8b\u5982\u4f60\u60f3\u77e5\u9053\u4f60\u7ed9\u591a\u5c11\u4e2a\u9879\u76ee\u70b9\u4eae\u8fc7\u661f\u661f\u3001\u6700\u521d3\u4e2a\u9879\u76ee\u7684\u540d\u5b57\u3001\u53ca\u4ed6\u4eecstar fork watcher\u7684\u603b\u6570\u53ef\u4ee5\u770b\u5230\uff0c\u8fd4\u56de\u7684 JSON \u6570\u636e\u4e2d\uff0ckey value \u662f\u548c\u8bf7\u6c42\u5b8c\u5168\u4e00\u81f4\u7684\n<\/p>\n<p>\n\tGraphQL \u8bf7\u6c42\u5c31\u662f\u8fd9\u6837\u7684\u3002\n<\/p>\n<pre class=\"brush:plain;\">\r\n{\r\n viewer {\r\n   login\r\n   starredRepositories {\r\n     totalCount\r\n   }\r\n   repositories(first: 3) {\r\n     edges {\r\n       node {\r\n         name\r\n         stargazers {\r\n           totalCount\r\n         }\r\n         forks {\r\n           totalCount\r\n         }\r\n         watchers {\r\n           totalCount\r\n         }\r\n         issues(states:[OPEN]) {\r\n           totalCount\r\n         }\r\n       }\r\n     }\r\n   }\r\n }\r\n}<\/pre>\n<p>\n\t\u54cd\u5e94\u4fe1\u606f\u5982\u4e0b\n<\/p>\n<pre class=\"brush:plain;\">\r\n{  \r\n &quot;data&quot;:{  \r\n   &quot;viewer&quot;:{  \r\n     &quot;login&quot;: &quot;octocat&quot;,\r\n     &quot;starredRepositories&quot;: {\r\n       &quot;totalCount&quot;: 131\r\n     },\r\n     &quot;repositories&quot;:{\r\n       &quot;edges&quot;:[\r\n         {\r\n           &quot;node&quot;:{\r\n             &quot;name&quot;:&quot;octokit.rb&quot;,\r\n             &quot;stargazers&quot;:{\r\n               &quot;totalCount&quot;: 17\r\n             },\r\n             &quot;forks&quot;:{\r\n               &quot;totalCount&quot;: 3\r\n             },\r\n             &quot;watchers&quot;:{\r\n               &quot;totalCount&quot;: 3\r\n             },\r\n             &quot;issues&quot;: {\r\n               &quot;totalCount&quot;: 1\r\n             }\r\n           }\r\n         },\r\n         {  \r\n           &quot;node&quot;:{  \r\n             &quot;name&quot;:&quot;octokit.objc&quot;,\r\n             &quot;stargazers&quot;:{\r\n               &quot;totalCount&quot;: 2\r\n             },\r\n             &quot;forks&quot;:{\r\n               &quot;totalCount&quot;: 0\r\n             },\r\n             &quot;watchers&quot;:{\r\n               &quot;totalCount&quot;: 1\r\n             },\r\n             &quot;issues&quot;: {\r\n               &quot;totalCount&quot;: 10\r\n             }\r\n           }\r\n         },\r\n         {\r\n           &quot;node&quot;:{\r\n             &quot;name&quot;:&quot;octokit.net&quot;,\r\n             &quot;stargazers&quot;:{\r\n               &quot;totalCount&quot;: 19\r\n             },\r\n             &quot;forks&quot;:{\r\n               &quot;totalCount&quot;: 7\r\n             },\r\n             &quot;watchers&quot;:{\r\n               &quot;totalCount&quot;: 3\r\n             },\r\n             &quot;issues&quot;: {\r\n               &quot;totalCount&quot;: 4\r\n             }\r\n           }\r\n         }\r\n       ]\r\n     }\r\n   }\r\n }\r\n}<\/pre>\n<p>\n\tGraphQL \u8fd8\u6709\u5f88\u591a\u5176\u4ed6\u7684\u7279\u70b9\uff0c\u4f8b\u5982\u4f60\u53ea\u9700\u8981\u4e00\u4e2a\u8bf7\u6c42\uff0c\u5c31\u53ef\u4ee5\u5f97\u5230\u6240\u6709\u9700\u8981\u7684\u6570\u636e\u3002\n<\/p>\n<ul>\n<li>\n\t\t\u6279\u91cf\u8bf7\u6c42\uff0c\u53ef\u4ee5\u5b9a\u4e49\u4e24\u4e2a\u72ec\u7acb\u8bf7\u6c42\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u9ad8\u6548\u7684\u83b7\u53d6\u6570\u636e\n\t<\/li>\n<li>\n\t\t\u521b\u5efa\u8ba2\u9605\uff0cclient \u53ef\u4ee5\u6536\u5230\u65b0\u7684\u6570\u636e\n\t<\/li>\n<li>\n\t\t\u6570\u636e\u5ef6\u8fdf\uff0c\u53ef\u4ee5\u5bf9\u54cd\u5e94\u4e2d\u4e00\u90e8\u5206\u6570\u636e\u6807\u8bc6\u4e3a\u65f6\u95f4\u4e0d\u654f\u611f\n\t<\/li>\n<\/ul>\n<p>\n\t\u4e0d\u53ea\u662f Github\uff0c\u8fd8\u6709\u5f88\u591a\u5927\u516c\u53f8\u5df2\u7ecf\u4f7f\u7528 GraphQL\uff0c\u4f8b\u5982 Pinterest, Coursera, Shopify\u3002<br \/>\n\tGithub \u4e5f\u8868\u8fbe\u4e86\u5bf9 GraphQL API \u7684\u91cd\u89c6\uff0c\u63a5\u4e0b\u6765\u4f1a\u6301\u7eed\u5b8c\u5584\uff0c\u4f7f\u5176\u66f4\u52a0\u7075\u6d3b\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=1585\">Github GraphQL \u4ecb\u7ecd<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u73b0\u5728\u6211\u8d8a\u6765\u8d8a\u610f\u8bc6\u5230\u82f1\u8bed\u7684\u91cd\u8981\u6027\u4e86\u3002\u5f88\u591a\u77e5\u8bc6\u70b9\u7f3a\u5c11\u4e2d\u6587\u8d44\u6599\uff0c\u800c\u82f1\u6587\u5374\u6709\u5f88\u591a\u535a\u6587\u3002\u5e0c\u671b\u4eba\u5de5\u667a\u80fd\u5728\u8fd9\u65b9\u9762\u80fd\u5e2e\u5230\u6211\u3002  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[1326,1106,806],"class_list":["post-1585","post","type-post","status-publish","format-standard","hentry","category-html5","tag-graphql","tag-javascript","tag-rest-api"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1585"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1585\/revisions"}],"predecessor-version":[{"id":1586,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1585\/revisions\/1586"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}