{"id":18039,"date":"2022-10-03T17:28:13","date_gmt":"2022-10-03T08:28:13","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=18039"},"modified":"2023-05-27T20:25:59","modified_gmt":"2023-05-27T11:25:59","slug":"%e3%80%90graphql%e3%80%91%e6%a7%8b%e6%88%90","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=18039","title":{"rendered":"\u3010GraphQL\u3011\u69cb\u6210\uff08\u300c\u30af\u30a8\u30ea\u8a00\u8a9e\u300d\u3001\u300c\u30b9\u30ad\u30fc\u30de\u8a00\u8a9e\u300d\uff09"},"content":{"rendered":"<p>GraphQL\u306f\u300c\u30af\u30a8\u30ea\u8a00\u8a9e\u300d\u3068\u300c\u30b9\u30ad\u30fc\u30de\u8a00\u8a9e\u300d\u306e\u4e8c\u3064\u306b\u5206\u304b\u308c\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u30af\u30a8\u30ea\u8a00\u8a9e<\/li>\n<li>\u30b9\u30ad\u30fc\u30de\u8a00\u8a9e<\/li>\n<\/ul>\n<h2>\u30af\u30a8\u30ea\u8a00\u8a9e<\/h2>\n<p>\u30d5\u30ed\u30f3\u30c8\u5074\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u3002\u30eb\u30fc\u30c8\u578b\u3067\u59cb\u307e\u308b\u3002\u3053\u308c\u3092\u4f7f\u3046\u3053\u3068\u3067\u30c7\u30fc\u30bf\u30bd\u30fc\u30b9\u3078\u306e\u30a2\u30af\u30bb\u30b9\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>\u30eb\u30fc\u30c8\u578b<\/h3>\n<h4>query<\/h4>\n<p>\u30c7\u30fc\u30bf\u53d6\u5f97\u7cfb\u3001GET<\/p>\n<h5>\u5f15\u6570\u306a\u3057<\/h5>\n<pre class=\"lang:default decode:true \">query {\r\n  \u30ea\u30be\u30eb\u30d0\u95a2\u6570\u540d\r\n}<\/pre>\n<h5>\u5f15\u6570\u3042\u308a<\/h5>\n<pre class=\"lang:default decode:true\">query {\r\n  \u30ea\u30be\u30eb\u30d0\u95a2\u6570\u540d(\u5f15\u65701: xxx, \u5f15\u65702: yyy)\r\n}<\/pre>\n<h4>mutation<\/h4>\n<p>\u30c7\u30fc\u30bf\u66f4\u65b0\u7cfb\u3001POST\/PUT\/DELETE<\/p>\n<h4>subscription<\/h4>\n<p>\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u304b\u3089\u306e\u30a4\u30d9\u30f3\u30c8\u901a\u77e5\u3001Websocket<\/p>\n<h3>\u30b9\u30ab\u30e9\u30fc\u578b<\/h3>\n<p>5\u7a2e\u985e\u3042\u308a\u307e\u3059\u3002\u305d\u308c\u305e\u308c\u306e\u30c7\u30fc\u30bf\u578b\u306f\u89d2\u62ec\u5f27\u3067\u56f2\u3046\u3053\u3068\u306b\u3088\u3063\u3066<span style=\"color: #ff0000;\"><strong>\u30ea\u30b9\u30c8<\/strong><\/span>\u3068\u3057\u3066\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u306f\u53ef\u80fd\u3067\u3059\u3002\u307e\u305f\u3001null\u306b\u306a\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u30d5\u30a3\u30fc\u30eb\u30c9\u306f<span style=\"color: #ff0000;\"><strong>!\uff08\u30a8\u30af\u30b9\u30af\u30e9\u30e1\u30fc\u30b7\u30e7\u30f3\u30de\u30fc\u30af\uff09<\/strong><\/span>\u3092\u3064\u3051\u307e\u3059\u3002<\/p>\n<h4>String<\/h4>\n<p>\u6587\u5b57\u5217\u578b\u3001JSON\u3067\u306fstring<\/p>\n<h4>Int<\/h4>\n<p>\u6574\u6570\u578b\u3001JSON\u3067\u306fnumber<\/p>\n<h4>Float<\/h4>\n<p>\u6d6e\u52d5\u5c0f\u6570\u70b9\u578b\u3001JSON\u3067\u306fnumber<\/p>\n<h4>Boolean<\/h4>\n<p>\u8ad6\u7406\u578b<\/p>\n<h4>ID<\/h4>\n<p>ID\u578b\u3001JSON\u3067\u306fstring<\/p>\n<h2>\u30b9\u30ad\u30fc\u30de\u8a00\u8a9e(SDL)<\/h2>\n<p>\u30b5\u30fc\u30d0\u30fc\u5074\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u3001GraphQL\u306eAPI\u4ed5\u69d8\u3092\u8a18\u8ff0\u3059\u308b\u305f\u3081\u306e\u8a00\u8a9e<\/p>\n<p>\u30af\u30a8\u30ea\u8a00\u8a9e\u304b\u3089\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u306f\u30b9\u30ad\u30fc\u30de\u8a00\u8a9e\u3067\u8a18\u8ff0\u3057\u305f\u30b9\u30ad\u30fc\u30de\u306b\u6cbf\u3063\u3066GraphQL\u51e6\u7406\u7cfb\u306b\u3088\u308a\u5b9f\u884c\u3055\u308c\u3066\u3001\u30c7\u30fc\u30bf\u30b0\u30e9\u30d5\u69cb\u9020\u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8fd4\u3059\u3002<\/p>\n<p>\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3084\u8a00\u8a9e\u306b\u4f9d\u5b58\u305b\u305a\u306b\u5b9a\u7fa9\u3067\u304d\u308b\u306e\u304c\u7279\u5fb4<\/p>\n<p>\u30b9\u30ad\u30fc\u30de\u8a00\u8a9e\u306f\u3042\u304f\u307e\u3067\u4ed5\u69d8\u306e\u5b9a\u7fa9\u306b\u5fb9\u3059\u308b\u3082\u306e\u3067\u3042\u308a\u3001\u5b9f\u969b\u306e\u30c7\u30fc\u30bf\u64cd\u4f5c\u306f\u884c\u308f\u306a\u3044\u3002<\/p>\n<h3>\u30b9\u30ad\u30fc\u30de\u5b9a\u7fa9<\/h3>\n<p>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u304b\u3089\u64cd\u4f5c\u3067\u304d\u308b\u30af\u30a8\u30ea\u3092\u4e8b\u524d\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n<h3>\u30ea\u30be\u30eb\u30d0\u95a2\u6570<\/h3>\n<p>\u5b9f\u969b\u306e\u30c7\u30fc\u30bf\u3092\u64cd\u4f5c\u3092\u884c\u3046\u95a2\u6570\uff08\u30e1\u30bd\u30c3\u30c9\uff09\u306e\u3053\u3068\u3002<span style=\"color: #ff0000;\"><strong>\u30b9\u30ad\u30fc\u30de\u5b9a\u7fa9\u3092\u3057\u305f\u3089\u5fc5\u305a\u305d\u308c\u306b\u5bfe\u5fdc\u3059\u308b\u30ea\u30be\u30eb\u30d0\u95a2\u6570\u3092\u4f5c\u6210\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/strong><\/span>\uff08\u3053\u306e\u4f8b\u3067\u3044\u3048\u3070\u3001hello\u3068\u3044\u3046\u30b9\u30ad\u30fc\u30de\u3092\u5b9a\u7fa9\u3057\u305f\u306e\u3067\u3001hello\u3068\u3044\u3046\u30ea\u30be\u30eb\u30d0\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002\uff09<\/p>\n<pre class=\"lang:default decode:true  \">const express = require(\"express\");\r\nconst { graphqlHTTP } = require(\"express-graphql\");\r\nconst { buildSchema } = require(\"graphql\");\r\n\r\n\/\/ \u30b9\u30ad\u30fc\u30de\u5b9a\u7fa9\r\nconst schema = buildSchema(`type Query {hello:String}`);\r\n\r\n\/\/ \u30ea\u30be\u30eb\u30d0\u95a2\u6570\r\nconst root = {\r\n  hello: () =&gt; {\r\n    return \"Hello world!\";\r\n  },\r\n};\r\n\r\napp.use(\r\n  \"\/graphql\",\r\n  graphqlHTTP({ schema: schema, rootValue: root, graphiql: true })\r\n);\r\n\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"GraphQL\u306f\u300c\u30af\u30a8\u30ea\u8a00\u8a9e\u300d\u3068\u300c\u30b9\u30ad\u30fc\u30de\u8a00\u8a9e\u300d\u306e\u4e8c\u3064\u306b\u5206\u304b\u308c\u307e\u3059\u3002 \u30af\u30a8\u30ea\u8a00\u8a9e \u30b9\u30ad\u30fc\u30de\u8a00\u8a9e \u30af\u30a8\u30ea\u8a00\u8a9e \u30d5\u30ed\u30f3\u30c8\u5074\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u3002\u30eb\u30fc\u30c8\u578b\u3067\u59cb\u307e\u308b\u3002\u3053\u308c\u3092\u4f7f\u3046\u3053\u3068\u3067\u30c7\u30fc\u30bf\u30bd\u30fc\u30b9\u3078\u306e\u30a2\u30af\u30bb\u30b9\u304c\u3067\u304d\u307e\u3059\u3002 \u30eb\u30fc\u30c8\u578b que [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[125],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/18039"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=18039"}],"version-history":[{"count":9,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/18039\/revisions"}],"predecessor-version":[{"id":20213,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/18039\/revisions\/20213"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=18039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=18039"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=18039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}