{"id":47568,"date":"2023-03-16T20:30:15","date_gmt":"2023-01-22T04:54:23","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8apollo-client%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8graphql%e5%92%8c%e7%8a%b6%e6%80%81%e7%ae%a1%e7%90%86\/"},"modified":"2024-04-29T19:11:05","modified_gmt":"2024-04-29T11:11:05","slug":"%e4%bd%bf%e7%94%a8apollo-client%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8graphql%e5%92%8c%e7%8a%b6%e6%80%81%e7%ae%a1%e7%90%86","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8apollo-client%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8graphql%e5%92%8c%e7%8a%b6%e6%80%81%e7%ae%a1%e7%90%86\/","title":{"rendered":"\u4f7f\u7528Apollo Client\u5f00\u59cb\u4f7f\u7528GraphQL\u548c\u72b6\u6001\u7ba1\u7406"},"content":{"rendered":"<h2>\u8fd9\u662f\u5173\u4e8eGraphQL\u53ca\u5176\u5ba2\u6237\u7aef\u5e93&#8221; Apollo Client&#8221;\u7684\u8ba8\u8bba\u3002<\/h2>\n<hr \/>\n<p>\u8fd9\u662f\u4e00\u4e2a\u9762\u5411\u4f7f\u7528GraphQL\u8fdb\u884c\u5f00\u53d1\u7684\u56e2\u961f\u7684\u5185\u90e8\u5b66\u4e60\u4f1a\u7684\u8d44\u6599\u3002<\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u662f\u4e3a\u4e86\u4fc3\u8fdb\u5bf9GraphQL\u7684\u4f18\u52bf\u548c\u6574\u4f53\u6982\u5ff5\u7684\u7406\u89e3\u800c\u8fdb\u884c\u6a21\u677f\u5316\u7684\u3002<\/p>\n<hr \/>\n<h2>Topic: How to improve communication skills<\/h2>\n<p>\u5982\u4f55\u63d0\u5347\u6c9f\u901a\u6280\u5de7<\/p>\n<p>\u30fbGraphQL\u7684\u7279\u70b9<br \/>\n\u30fbApollo Client<br \/>\n\u30fbGraphQL Code Generator<br \/>\n\u30fb\u5f00\u53d1\u6d41\u7a0b<\/p>\n<hr \/>\n<h2>GraphQL\u7684\u7279\u70b9<\/h2>\n<hr \/>\n<h3>GraphQL\u7684\u7279\u70b9 &#8211; \u67b6\u6784<\/h3>\n<p>\u7528\u4f5c\u4e3aAPI\u548c\u5ba2\u6237\u7aef\u4e4b\u95f4\u7684\u63a5\u53e3\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"k\">type<\/span> <span class=\"n\">Post<\/span> <span class=\"p\">{<\/span>\r\n  <span class=\"n\">id<\/span><span class=\"p\">:<\/span> <span class=\"nb\">String<\/span><span class=\"p\">!<\/span>\r\n  <span class=\"n\">created_at<\/span><span class=\"p\">:<\/span> <span class=\"n\">DateTime<\/span><span class=\"p\">!<\/span>\r\n<span class=\"p\">}<\/span>\r\n<\/code><\/pre>\n<hr \/>\n<h3>GraphQL\u7684\u7279\u70b9-\u6a21\u5f0f<\/h3>\n<p>\u8fd9\u5c06\u4f1a\u88ab\u5ba2\u6237\u7aef\u7528\u4f5c\u8bf7\u6c42\/\u54cd\u5e94\u7c7b\u578b\u4fe1\u606f\u548c\u6570\u636e\u83b7\u53d6\u51fd\u6570\u7684\u81ea\u52a8\u751f\u6210\u3002<\/p>\n<hr \/>\n<h3>GraphQL\u7684\u7279\u70b9 &#8211; Schema<\/h3>\n<p>\u30fb\u901a\u8fc7\u8865\u5168\uff0c\u5f00\u53d1\u6548\u7387\u63d0\u9ad8\u4e86\u3002<br \/>\n\u30fb\u53d8\u5f97\u7c7b\u578b\u5b89\u5168\uff0c\u51cf\u8f7b\u4e86\u4fee\u590d\u548c\u91cd\u6784\u7684\u8d1f\u62c5\u3002<\/p>\n<p>\u6211\u53ea\u9700\u8981\u4e00\u4e2a\u9009\u9879\u6765\u5c06\u4ee5\u4e0b\u5185\u5bb9\u4ee5\u4e2d\u56fd\u7684\u6bcd\u8bed\u8fdb\u884c\u6539\u5199\uff1a\u60f3\u8981\u5927\u81f4\u4e86\u89e3API\u53d8\u66f4\u7684\u5f71\u54cd\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>npm run lint:ts\r\n<\/code><\/pre>\n<hr \/>\n<h3>GraphQL\u7684\u7279\u70b9\u4e0eREST\u8fdb\u884c\u6bd4\u8f83<\/h3>\n<p>\u30fb\u5ba2\u6237\u7aef\u6784\u5efa\u54cd\u5e94<br \/>\n\u30fb\u57fa\u672c\u4e0a\uff0c\u8d44\u6e90=\u89e3\u6790\u5668\uff08\u65e0\u9700\u7ba1\u7406\u5b50\u8d44\u6e90\u7684\u7ec8\u7ed3\u70b9\u5355\u4f4d\uff09<\/p>\n<p>\u6211\u5728\u6587\u7ae0\u9875\u9762\u7684API\u4e0a\u6dfb\u52a0\u4e86\u8bc4\u8bba\uff0c\u4f46\u662f\u6211\u73b0\u5728\u4e5f\u60f3\u8981\u5728\u5176\u4ed6\u9875\u9762\u83b7\u53d6\u8bc4\u8bba\u3002<\/p>\n<hr \/>\n<h3>GraphQL\u7684\u7279\u70b9-\u4e0eREST\u7684\u6bd4\u8f83<\/h3>\n<p>\u30fb\u53ef\u4ee5\u8bf4\u662f\u4ee5\u5ba2\u6237\u4e3a\u4e2d\u5fc3\u7684\u673a\u5236<br \/>\n\u30fb\u8003\u8651\u5230\u590d\u6742\u6027\u8f6c\u79fb\u7ed9\u5ba2\u6237\u7684\u80cc\u666f\uff0cGraphQL\u7684\u51fa\u73b0\u662f\u81ea\u7136\u7684\u80cc\u666f<br \/>\n\u30fb\u7531\u4e8e\u5b66\u4e60\u548c\u73af\u5883\u642d\u5efa\u6210\u672c\u9ad8\uff0c\u4e14\u5f88\u96be\u53d1\u6325\u51fa\u6027\u80fd\uff0c\u56e0\u6b64\u9700\u8981\u8c28\u614e\u9009\u62e9\u4f7f\u7528\u573a\u666f<\/p>\n<hr \/>\n<h2>\u963f\u6ce2\u7f57\u5ba2\u6237\u7aef<\/h2>\n<hr \/>\n<h3>\u963f\u6ce2\u7f57\u5ba2\u6237\u7aef<\/h3>\n<p>\u30fb\u5ba2\u6237\u7aef\u7684GraphQL\u5e93<br \/>\n\u30fb\u7531\u65e7Facebook\u5f00\u53d1\u7684Relay\u548c\u4e24\u4e2a\u5de8\u5934<br \/>\n\u30fb\u5c3d\u7ba1\u662f\u540e\u8d77\u4e4b\u79c0\uff0c\u4f46\u529f\u80fd\u4e30\u5bcc\u4e14\u7528\u6237\u4f17\u591a\uff0c\u4e0eRelay\u76f8\u6bd4\u9650\u5236\u8f83\u5f31<\/p>\n<p>&nbsp;<\/p>\n<hr \/>\n<h3>\u963f\u6ce2\u7f85\u5ba2\u6236\u7aef-\u72c0\u614b\u7ba1\u7406<\/h3>\n<p>\u5e0c\u671b\u53ef\u4ee5\u6a2a\u8de8\u7ec4\u4ef6\u5229\u7528\u7684\u72b6\u6001\u88ab\u79f0\u4e3a\u5168\u5c40\u72b6\u6001\uff0c\u5e76\u4e14\u5176\u7ba1\u7406\u65b9\u6cd5\u88ab\u79f0\u4e3a&#8221;\u72b6\u6001\u7ba1\u7406&#8221;\u3002<\/p>\n<p>\u5728\u72b6\u6001\u7ba1\u7406\u4e2d\u5904\u7406\u7684\u6570\u636e\u7c7b\u578b\u53ef\u4ee5\u5927\u81f4\u5206\u4e3a\u4e24\u79cd\uff1a<br \/>\n&#8211; \u901a\u8fc7API\u4f20\u9012\u7684\u6570\u636e<br \/>\n&#8211; \u5176\u4ed6\u6570\u636e\uff08\u5982\u663e\u793a\u5171\u7528\u6a21\u6001\u6846\u7b49\uff09<\/p>\n<hr \/>\n<h3>\u963f\u6ce2\u7f57\u5ba2\u6237\u7aef &#8211; \u72b6\u6001\u7ba1\u7406<\/h3>\n<p>\u4f7f\u7528Redux\u7b49\u5de5\u5177\u6765\u7ba1\u7406\u8de8\u7ec4\u4ef6\u4f7f\u7528\u7684\u5168\u5c40\u72b6\u6001\u5df2\u7ecf\u6210\u4e3a\u7406\u8bba\u5316\u7684\u65b9\u5f0f\u3002<\/p>\n<p>\u6211\u611f\u5230\u6709\u4ee5\u4e0b\u7684\u95ee\u9898\uff1a<br \/>\n&#8211; \u6709\u5f88\u591a\u6837\u677f\u4ee3\u7801\uff0c\u5f88\u9ebb\u70e6\u3002<br \/>\n&#8211; \u5982\u679c\u4ee3\u7801\u91cf\u589e\u52a0\uff0c\u9700\u8981\u6280\u672f\u4eba\u5458\u3002<\/p>\n<hr \/>\n<h3>Apollo Client \u662f\u4e00\u4e2a\u7528\u4e8e\u72b6\u6001\u7ba1\u7406\u7684\u5de5\u5177\u3002<\/h3>\n<p>\u968f\u7740 SWR \u548c useQuery \u8fd9\u6837\u7684\u5e26\u6709\u7f13\u5b58\u673a\u5236\u7684\u5e93\u7684\u6d41\u884c\u3002<\/p>\n<p>\u5177\u6709\u901a\u8fc7API\u8fdb\u884c\u6570\u636e\u8bbf\u95ee\u3001\u901a\u8fc7\u5176\u4ed6\u65b9\u5f0f\u8fdb\u884c\u6570\u636e\u8bbf\u95ee\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u6839\u636e\u8bc6\u522b\u7b26\u8fdb\u884c\u5185\u5b58\u7f13\u5b58\u3002<\/p>\n<hr \/>\n<h3>Apollo\u5ba2\u6237\u7aef &#8211; \u72b6\u6001\u7ba1\u7406<\/h3>\n<p>\u963f\u6ce2\u7f57\u8fd8\u5177\u6709\u7f13\u5b58\u673a\u5236\uff0c\u5e76\u4e14\u5177\u5907\u5c06\u6bcf\u4e2a\u5bf9\u8c61\u89c4\u8303\u5316\u7684\u529f\u80fd\u3002<\/p>\n<pre class=\"post-pre\"><code>\/\/ __typename x id\u3092\u8b58\u5225\u5b50\u3068\u3057\u3066\u30e6\u30cb\u30fc\u30af\u6027\u3092\u62c5\u4fdd\r\n{ __typename: 'Post', id: 'uuid-1', name: 'something' },\r\n{ __typename: 'Post', id: 'uuid-2', name: 'anything' }\r\n<\/code><\/pre>\n<hr \/>\n<h3>\u963f\u6ce2\u7f57\u5ba2\u6237\u7aef-\u72b6\u6001\u7ba1\u7406<\/h3>\n<p>\u53ef\u4ee5\u5b9e\u73b0\u4ee5\u4e0b\u884c\u4e3a\uff1a<br \/>\n&#8211; \u901a\u8fc7\u6570\u636e\u53d8\u5316\u6765\u66f4\u65b0\u6587\u7ae0<br \/>\n&#8211; \u66f4\u65b0\u6587\u7ae0\u5217\u8868\u7684\u7f13\u5b58<br \/>\n&#8211; \u66f4\u65b0\u6587\u7ae0\u5217\u8868\u7684\u663e\u793a<\/p>\n<p>\u5f53\u901a\u8fc7API\u66f4\u65b0\u6570\u636e\u65f6\uff0c\u4e0d\u518d\u9700\u8981\u66f4\u65b0\u5168\u5c40\u72b6\u6001\u3002?<\/p>\n<hr \/>\n<h3>Apollo Client &#8211; \u72b6\u6001\u7ba1\u7406<\/h3>\n<p>\u9664\u6b64\u4e4b\u5916\u7684\u6570\u636e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u201c\u54cd\u5e94\u5f0f\u53d8\u91cf\u201d\u8fd9\u4e2a\u529f\u80fd\uff0c\u50cf\u4ee5\u524d\u4e00\u6837\u624b\u52a8\u8fdb\u884c\u66f4\u6539\u3002<\/p>\n<hr \/>\n<h3>Apollo Client &#8211; \u72b6\u6001\u7ba1\u7406<\/h3>\n<pre class=\"post-pre\"><code>\/\/ store.js\r\nconst flagVar = makeVar(false);\r\n\r\n\/\/ component.jsx\r\nconst Component = () =&gt; {\r\n  const flag = useReactiveVar(flagVar); \/\/ reactive\u306b\u5909\u66f4\u3092\u691c\u77e5\r\n  return &lt;div onClick={() =&gt; flagVar(true)}&gt;{flag}&lt;\/div&gt;;\r\n}\r\n<\/code><\/pre>\n<hr \/>\n<h2>GraphQL\u4ee3\u7801\u751f\u6210\u5668<\/h2>\n<hr \/>\n<h3>GraphQL \u4ee3\u7801\u751f\u6210\u5668<\/h3>\n<p>\u80fd\u591f\u81ea\u52a8\u751f\u6210\u4ee5\u4e0b\u5185\u5bb9\u7684\u5de5\u5177\uff1a<br \/>\n&#8211; API\u54cd\u5e94\u7c7b\u578b<br \/>\n&#8211; \u6570\u636e\u83b7\u53d6\u7684\u94a9\u5b50<\/p>\n<p>&nbsp;<\/p>\n<hr \/>\n<h3>GraphQL \u4ee3\u7801\u751f\u6210\u5668<\/h3>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u81ea\u52a8\u751f\u6210\u7684\u4ee3\u7801\u53c2\u8003\u4e86\u4ee5\u4e0b\u5185\u5bb9\uff1a<br \/>\n\u00b7\u6a21\u5f0f<br \/>\n\u00b7\u64cd\u4f5c\u4ee3\u7801\uff08\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\uff09<\/p>\n<hr \/>\n<h3>GraphQL Code Generator &#8211; query\uff08\u67e5\u8be2\uff09<\/h3>\n<p>\u67b6\u6784<\/p>\n<pre class=\"post-pre\"><code>\/\/ \u30eb\u30fc\u30c8\u578b\r\ntype Query {\r\n  post: Post \/\/ \u30d5\u30a3\u30fc\u30eb\u30c9(REST\u306eendpoint\u306b\u76f8\u5f53)\r\n}\r\n\/\/ \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u578b\r\ntype Post { id: String! title: String }\r\n<\/code><\/pre>\n<hr \/>\n<h3>GraphQL \u4ee3\u7801\u751f\u6210\u5668 &#8211; \u67e5\u8be2\uff08\u53c2\u8003\uff09<\/h3>\n<p>\u64cd\u4f5c\u7801 (CaoZuoMa)<\/p>\n<pre class=\"post-pre\"><code>query PostPage { \/\/ \u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u30bf\u30a4\u30d7 \u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u30cd\u30fc\u30e0\r\n  post { \/\/ \u30d5\u30a3\u30fc\u30eb\u30c9\r\n    id\r\n    title\r\n  }\r\n}\r\n<\/code><\/pre>\n<hr \/>\n<h3>GraphQL\u4ee3\u7801\u751f\u6210\u5668 &#8211; \u67e5\u8be2(\u53c2\u8003)<\/h3>\n<p>\u751f\u6210\u7684\u4ee3\u7801\uff08\u8282\u9009\uff09<\/p>\n<pre class=\"post-pre\"><code>type PostPageQuery = { \/\/ \u30ec\u30b9\u30dd\u30f3\u30b9\u578b\r\n  __typename: 'Post';\r\n  id: string;\r\n  title: string | null | undefined;\r\n};\r\nconst usePostPageQuery = useQuery(...); \/\/ hooks\r\n<\/code><\/pre>\n<hr \/>\n<h3>GraphQL \u4ee3\u7801\u751f\u6210\u5668 &#8211; \u67e5\u8be2(\u53c2\u7167)<\/h3>\n<p>\u6302\u94a9\u7684\u4f7f\u7528\u65b9\u6cd5<\/p>\n<pre class=\"post-pre\"><code>const Component = () =&gt; {\r\n  const { data, loading, error } = usePostPageQuery();\r\n  if (error) return throw error; \/\/ \u30a8\u30e9\u30fc\r\n  if (loading) return &lt;div&gt;Loading&lt;\/div&gt;; \/\/ \u30ed\u30fc\u30c7\u30a3\u30f3\u30b0\u4e2d\r\n  return &lt;div&gt;{`${data.post.id}: ${data.post?.title}`}&lt;\/div&gt;;\r\n};\r\n<\/code><\/pre>\n<hr \/>\n<h3>GraphQL \u4ee3\u7801\u751f\u6210\u5668 &#8211; mutation(\u66f4\u65b0)<\/h3>\n<p>\u67b6\u6784<\/p>\n<pre class=\"post-pre\"><code>type Mutation {\r\n  update_post(input: UpdatePostInput!): UpdatePostMutation!\r\n}\r\ntype UpdatePostInput { id: String! title: String! } \/\/ \u30d1\u30e9\u30e1\u30fc\u30bf\r\ntype UpdatePostMutation { post: Post } \/\/ \u30ec\u30b9\u30dd\u30f3\u30b9\r\n<\/code><\/pre>\n<hr \/>\n<h3>GraphQL\u4ee3\u7801\u751f\u6210\u5668 &#8211; mutation\uff08\u66f4\u65b0\uff09<\/h3>\n<p>\u64cd\u4f5c\u7801<\/p>\n<pre class=\"post-pre\"><code>mutation PostPageUpdate($input: UpdatePostInput!) {\r\n  update_post(input: $input) {\r\n    id \/\/ \u3053\u3053\u304b\u3089\u30ec\u30b9\u30dd\u30f3\u30b9\r\n    title\r\n  }\r\n}\r\n<\/code><\/pre>\n<hr \/>\n<h3>GraphQL\u4ee3\u7801\u751f\u6210\u5668 &#8211; mutation\uff08\u66f4\u65b0\uff09<\/h3>\n<p>\u751f\u6210\u7684\u4ee3\u7801\uff08\u6458\u5f55\uff09<\/p>\n<pre class=\"post-pre\"><code>type PostPageUpdateMutation = { \/\/ \u30ec\u30b9\u30dd\u30f3\u30b9\u578b\r\n  __typename: 'PostPageUpdateMutation';\r\n  post: Post;\r\n};\r\nconst usePostPageUpdateMutatiion = useMutation(...); \/\/ hooks\r\n<\/code><\/pre>\n<hr \/>\n<h3>GraphQL \u4ee3\u7801\u751f\u6210\u5668 &#8211; mutation(\u66f4\u65b0)<\/h3>\n<p>\u94a9\u5b50\u7684\u7528\u6cd5<\/p>\n<pre class=\"post-pre\"><code>const Component = () =&gt; {\r\n  const [mutate] = usePostPageUpdateMutatiion(); \/\/ \u95a2\u6570\u53d6\u5f97\r\n  const handleUpdate = async () =&gt; {\r\n    const { error } = await mutate();\r\n    if (error) return throw error; \/\/ \u30a8\u30e9\u30fc\r\n  };\r\n  return &lt;button onClick={handleUpdate}&gt;&lt;\/button&gt;;\r\n};\r\n<\/code><\/pre>\n<hr \/>\n<h2>\u5f00\u53d1\u7684\u8fc7\u7a0b<\/h2>\n<hr \/>\n<h2>\u5f00\u53d1\u6d41\u7a0b<\/h2>\n<p>GraphQL\u7684\u5f00\u53d1\u65b9\u6cd5\u4e3b\u8981\u6709\u4e24\u79cd\uff1a<br \/>\n\u30fbCode First<br \/>\n\u901a\u8fc7\u5b9a\u4e49\u7c7b\u578b\u548c\u89e3\u6790\u5668\u751f\u6210\u6a21\u5f0f\uff08\u6211\u4eec\u91c7\u7528\u8fd9\u79cd\u65b9\u6cd5\uff09<br \/>\n\u30fbSchema First<br \/>\n\u901a\u8fc7\u6a21\u5f0f\u751f\u6210\u4ee3\u7801\uff08\u5982gqlgen\uff09<\/p>\n<hr \/>\n<h2>\u5f00\u53d1\u7684\u8fc7\u7a0b<\/h2>\n<p>[BE] \u8868\u683c\u8bbe\u8ba1<br \/>\n[ALL] \u6839\u636eER\u56fe\u548c\u8bbe\u8ba1\u6765\u8ba8\u8bba\u6a21\u5f0f<br \/>\n[BE] \u7f16\u5199\u8d44\u6e90\u7c7b\u578b\u548c\u89e3\u6790\u5668\uff08\u903b\u8f91\uff09\u4ee3\u7801<br \/>\n[BE] \u81ea\u52a8\u751f\u6210\u6a21\u5f0f<br \/>\n[FE] \u7f16\u5199\u64cd\u4f5c\u4ee3\u7801<br \/>\n[FE] \u81ea\u52a8\u751f\u6210\u54cd\u5e94\u7c7b\u578b\u548chooks<\/p>\n<hr \/>\n<h2>\u5f00\u53d1\u6d41\u7a0b &#8211; \u96be\u9898<\/h2>\n<p>\u8fd9\u4e2a\u56e2\u961f\u5206\u4e3aBE\uff08\u540e\u7aef\u5de5\u7a0b\u5e08\uff09\u548cFE\uff08\u524d\u7aef\u5de5\u7a0b\u5e08\uff09\uff0c\u7531\u4e8e\u91c7\u7528\u4e86\u4ee3\u7801\u4f18\u5148\u7684\u65b9\u5f0f\uff0c\u7ecf\u5e38\u4f1a\u9519\u8fc7\u8ba8\u8bba\u6570\u636e\u5e93\u8bbe\u8ba1\u7684\u65f6\u673a\u3002<br \/>\n\u4e00\u65e6\u5b8c\u6210\u4e86\u8bbe\u8ba1\u548cER\u56fe\uff0c\u5c31\u53ef\u4ee5\u5728\u8fd9\u4e2a\u65f6\u95f4\u70b9\u4e0a\u8ba8\u8bba\u6570\u636e\u5e93\u8bbe\u8ba1\uff0c\u8fd9\u6837\u53ef\u4ee5\u987a\u5229\u5730\u63a8\u8fdb\u5b9e\u65bd\u5de5\u4f5c\u3002<\/p>\n<hr \/>\n<h2>\u6700\u540e<\/h2>\n<p>\u6211\u5728Kibela\u4e0a\u521b\u5efa\u4e86\u6587\u6863 ?<br \/>\n\u91cc\u9762\u8bb0\u5f55\u4e86\u5e38\u7528\u672f\u8bed\u548c\u5e93\u7684API\uff0c\u8bf7\u5728\u56f0\u96be\u65f6\u53c2\u9605\u3002<\/p>\n<p>\u30fbGraphQL\u672f\u8bed\u96c6\u5408<br \/>\n\u30fb[\u524d\u7aef] \u5982\u4f55\u4f7f\u7528ApolloClient<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u662f\u5173\u4e8eGraphQL\u53ca\u5176\u5ba2\u6237\u7aef\u5e93&#8221; Apollo Client&#8221;\u7684\u8ba8\u8bba\u3002 \u8fd9\u662f\u4e00\u4e2a\u9762 [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-47568","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f7f\u7528Apollo Client\u5f00\u59cb\u4f7f\u7528GraphQL\u548c\u72b6\u6001\u7ba1\u7406 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528apollo-client\u5f00\u59cb\u4f7f\u7528graphql\u548c\u72b6\u6001\u7ba1\u7406\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f7f\u7528Apollo Client\u5f00\u59cb\u4f7f\u7528GraphQL\u548c\u72b6\u6001\u7ba1\u7406\" \/>\n<meta property=\"og:description\" content=\"\u8fd9\u662f\u5173\u4e8eGraphQL\u53ca\u5176\u5ba2\u6237\u7aef\u5e93&#8221; Apollo Client&#8221;\u7684\u8ba8\u8bba\u3002 \u8fd9\u662f\u4e00\u4e2a\u9762 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528apollo-client\u5f00\u59cb\u4f7f\u7528graphql\u548c\u72b6\u6001\u7ba1\u7406\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-22T04:54:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T11:11:05+00:00\" \/>\n<meta name=\"author\" content=\"\u6e05, \u626c\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6e05, \u626c\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8apollo-client%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8graphql%e5%92%8c%e7%8a%b6%e6%80%81%e7%ae%a1%e7%90%86\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8apollo-client%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8graphql%e5%92%8c%e7%8a%b6%e6%80%81%e7%ae%a1%e7%90%86\/\",\"name\":\"\u4f7f\u7528Apollo Client\u5f00\u59cb\u4f7f\u7528GraphQL\u548c\u72b6\u6001\u7ba1\u7406 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-01-22T04:54:23+00:00\",\"dateModified\":\"2024-04-29T11:11:05+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8apollo-client%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8graphql%e5%92%8c%e7%8a%b6%e6%80%81%e7%ae%a1%e7%90%86\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8apollo-client%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8graphql%e5%92%8c%e7%8a%b6%e6%80%81%e7%ae%a1%e7%90%86\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8apollo-client%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8graphql%e5%92%8c%e7%8a%b6%e6%80%81%e7%ae%a1%e7%90%86\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f7f\u7528Apollo Client\u5f00\u59cb\u4f7f\u7528GraphQL\u548c\u72b6\u6001\u7ba1\u7406\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461\",\"name\":\"\u6e05, \u626c\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g\",\"caption\":\"\u6e05, \u626c\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyang\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8apollo-client%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8graphql%e5%92%8c%e7%8a%b6%e6%80%81%e7%ae%a1%e7%90%86\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u4f7f\u7528Apollo Client\u5f00\u59cb\u4f7f\u7528GraphQL\u548c\u72b6\u6001\u7ba1\u7406 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528apollo-client\u5f00\u59cb\u4f7f\u7528graphql\u548c\u72b6\u6001\u7ba1\u7406\/","og_locale":"zh_CN","og_type":"article","og_title":"\u4f7f\u7528Apollo Client\u5f00\u59cb\u4f7f\u7528GraphQL\u548c\u72b6\u6001\u7ba1\u7406","og_description":"\u8fd9\u662f\u5173\u4e8eGraphQL\u53ca\u5176\u5ba2\u6237\u7aef\u5e93&#8221; Apollo Client&#8221;\u7684\u8ba8\u8bba\u3002 \u8fd9\u662f\u4e00\u4e2a\u9762 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528apollo-client\u5f00\u59cb\u4f7f\u7528graphql\u548c\u72b6\u6001\u7ba1\u7406\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-01-22T04:54:23+00:00","article_modified_time":"2024-04-29T11:11:05+00:00","author":"\u6e05, \u626c","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u6e05, \u626c","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8apollo-client%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8graphql%e5%92%8c%e7%8a%b6%e6%80%81%e7%ae%a1%e7%90%86\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8apollo-client%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8graphql%e5%92%8c%e7%8a%b6%e6%80%81%e7%ae%a1%e7%90%86\/","name":"\u4f7f\u7528Apollo Client\u5f00\u59cb\u4f7f\u7528GraphQL\u548c\u72b6\u6001\u7ba1\u7406 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-01-22T04:54:23+00:00","dateModified":"2024-04-29T11:11:05+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8apollo-client%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8graphql%e5%92%8c%e7%8a%b6%e6%80%81%e7%ae%a1%e7%90%86\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8apollo-client%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8graphql%e5%92%8c%e7%8a%b6%e6%80%81%e7%ae%a1%e7%90%86\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8apollo-client%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8graphql%e5%92%8c%e7%8a%b6%e6%80%81%e7%ae%a1%e7%90%86\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u4f7f\u7528Apollo Client\u5f00\u59cb\u4f7f\u7528GraphQL\u548c\u72b6\u6001\u7ba1\u7406"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461","name":"\u6e05, \u626c","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g","caption":"\u6e05, \u626c"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyang\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8apollo-client%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8graphql%e5%92%8c%e7%8a%b6%e6%80%81%e7%ae%a1%e7%90%86\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/47568","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=47568"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/47568\/revisions"}],"predecessor-version":[{"id":87110,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/47568\/revisions\/87110"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=47568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=47568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=47568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}