{"id":1989,"date":"2024-10-03T12:14:29","date_gmt":"2024-10-03T03:14:29","guid":{"rendered":"https:\/\/hyunsu.com\/wordpress\/?p=1989"},"modified":"2024-10-03T12:15:50","modified_gmt":"2024-10-03T03:15:50","slug":"graphql%ec%9d%98-%ec%bf%bc%eb%a6%acquery%ec%99%80-%eb%ae%a4%ed%85%8c%ec%9d%b4%ec%85%98mutation","status":"publish","type":"post","link":"https:\/\/hyunsu.com\/wordpress\/?p=1989","title":{"rendered":"GraphQL\uc758 \ucffc\ub9ac(Query)\uc640 \ubba4\ud14c\uc774\uc158(Mutation)"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\"><strong>1. \ucffc\ub9ac(Query) \uc791\uc131\ud558\uae30<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\ucffc\ub9ac\ub780 \ubb34\uc5c7\uc778\uac00?<\/strong><\/h4>\n\n\n\n<p>GraphQL\uc5d0\uc11c <strong>\ucffc\ub9ac<\/strong>\ub294 \uc11c\ubc84\ub85c\ubd80\ud130 \ub370\uc774\ud130\ub97c \uc694\uccad\ud558\ub294 \uc791\uc5c5\uc744 \uc758\ubbf8\ud569\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4, REST API\uc5d0\uc11c \ub370\uc774\ud130\ub97c \uac00\uc838\uc624\ub294 GET \uc694\uccad\uacfc \ube44\uc2b7\ud55c \uac1c\ub150\uc774\uc5d0\uc694. GraphQL \ucffc\ub9ac\uc758 \uac00\uc7a5 \ud070 \uc7a5\uc810\uc740 <strong>\ud544\uc694\ud55c \ub370\uc774\ud130\ub9cc \uc815\ud655\ud558\uac8c \uc694\uccad<\/strong>\ud560 \uc218 \uc788\ub2e4\ub294 \uac83\uc785\ub2c8\ub2e4.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\uae30\ubcf8 \ucffc\ub9ac \uc608\uc81c<\/strong><\/h4>\n\n\n\n<p>\uc0ac\uc6a9\uc790 \uc815\ubcf4\ub97c \uc694\uccad\ud558\ub294 \ucffc\ub9ac\ub97c \uc608\uc2dc\ub85c \ub4e4\uc5b4\ubcfc\uac8c\uc694. \uc774 \uc608\uc2dc\ub294 \uc0ac\uc6a9\uc790\uc758 <code>name<\/code>\uacfc <code>email<\/code> \uc815\ubcf4\ub97c \uac00\uc838\uc624\ub294 \ucffc\ub9ac\uc785\ub2c8\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>query {<br>  user(id: 1) {<br>    name<br>    email<br>  }<br>}<br><\/code><\/pre>\n\n\n\n<p>\uc774 \ucffc\ub9ac\ub294 \uc11c\ubc84\uc5d0 <code>id<\/code>\uac00 1\uc778 \uc0ac\uc6a9\uc790\uc758 <code>name<\/code>\uacfc <code>email<\/code>\uc744 \uc694\uccad\ud558\ub294 \uac83\uc785\ub2c8\ub2e4. \uc11c\ubc84\ub294 \uc694\uccad\ud55c \uc815\ubcf4\ub9cc \uc815\ud655\ud558\uac8c \ubc18\ud658\ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\uc911\ucca9 \ucffc\ub9ac(Nested Query)<\/strong><\/h4>\n\n\n\n<p>GraphQL\uc5d0\uc11c\ub294 \ub370\uc774\ud130\ub97c <strong>\uc911\ucca9<\/strong>\ud574\uc11c \uc694\uccad\ud560 \uc218\ub3c4 \uc788\uc2b5\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4, \uc0ac\uc6a9\uc790\uc758 \uc815\ubcf4\uc640 \uadf8 \uc0ac\uc6a9\uc790\uac00 \uc4f4 \uac8c\uc2dc\ubb3c\uc758 \uc815\ubcf4\ub97c \ud55c \ubc88\uc5d0 \uc694\uccad\ud560 \uc218 \uc788\uc5b4\uc694.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>query {<br>  user(id: 1) {<br>    name<br>    posts {<br>      title<br>      content<br>    }<br>  }<br>}<br><\/code><\/pre>\n\n\n\n<p>\uc774 \ucffc\ub9ac\ub294 <code>id<\/code>\uac00 1\uc778 \uc0ac\uc6a9\uc790\uc758 \uc774\ub984(<code>name<\/code>)\uacfc \uadf8 \uc0ac\uc6a9\uc790\uac00 \uc4f4 \uac8c\uc2dc\ubb3c\ub4e4\uc758 \uc81c\ubaa9(<code>title<\/code>)\uacfc \ub0b4\uc6a9(<code>content<\/code>)\uc744 \ud55c \ubc88\uc5d0 \uc694\uccad\ud558\ub294 \uc608\uc2dc\uc785\ub2c8\ub2e4.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\ub9e4\uac1c\ubcc0\uc218(Parameter) \uc0ac\uc6a9\ud558\uae30<\/strong><\/h4>\n\n\n\n<p>GraphQL \ucffc\ub9ac\uc5d0\uc11c\ub294 \ub9e4\uac1c\ubcc0\uc218\ub97c \uc0ac\uc6a9\ud574 \uc694\uccad\uc744 \ub3d9\uc801\uc73c\ub85c \ub9cc\ub4e4 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4, \ud2b9\uc815 \uc0ac\uc6a9\uc790\ub97c \uc694\uccad\ud560 \ub54c\ub9c8\ub2e4 \ub2e4\ub978 <code>id<\/code>\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\uc5b4\uc694.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>query getUser($userId: ID!) {<br>  user(id: $userId) {<br>    name<br>    email<br>  }<br>}<br><\/code><\/pre>\n\n\n\n<p>\uc5ec\uae30\uc11c <code>$userId<\/code>\ub294 \ubcc0\uc218\ub85c \uc0ac\uc6a9\ub429\ub2c8\ub2e4. \uc2e4\uc81c \uc694\uccad\uc744 \ubcf4\ub0bc \ub54c\ub294 \uc774 \ubcc0\uc218\ub97c \uc9c0\uc815\ud574\uc11c \ub370\uc774\ud130\ub97c \uc694\uccad\ud560 \uc218 \uc788\uc5b4\uc694. \uc608\ub97c \ub4e4\uc5b4, <code>userId<\/code>\uc5d0 <code>2<\/code>\ub97c \ub123\uc73c\uba74, <code>id<\/code>\uac00 2\uc778 \uc0ac\uc6a9\uc790\uc758 \uc815\ubcf4\ub97c \ubc1b\uc544\uc62c \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. \ubba4\ud14c\uc774\uc158(Mutation) \uc791\uc131\ud558\uae30<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\ubba4\ud14c\uc774\uc158\uc774\ub780?<\/strong><\/h4>\n\n\n\n<p>\ubba4\ud14c\uc774\uc158\uc740 \ub370\uc774\ud130\ub97c \uc11c\ubc84\uc5d0 <strong>\ucd94\uac00<\/strong>\ud558\uac70\ub098 <strong>\uc218\uc815<\/strong>, <strong>\uc0ad\uc81c<\/strong>\ud560 \ub54c \uc0ac\uc6a9\ud558\ub294 \uc791\uc5c5\uc785\ub2c8\ub2e4. REST API\uc758 POST, PUT, DELETE\uc640 \uac19\uc740 \uae30\ub2a5\uc744 \uc218\ud589\ud55c\ub2e4\uace0 \ubcf4\uc2dc\uba74 \ub429\ub2c8\ub2e4.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\uae30\ubcf8 \ubba4\ud14c\uc774\uc158 \uc608\uc81c<\/strong><\/h4>\n\n\n\n<p>\uc0c8\ub85c\uc6b4 \uc0ac\uc6a9\uc790\ub97c \ucd94\uac00\ud558\ub294 \ubba4\ud14c\uc774\uc158 \uc608\uc81c\ub97c \uc0b4\ud3b4\ubcfc\uac8c\uc694.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mutation {<br>  addUser(name: \"Alice\", email: \"alice@example.com\") {<br>    id<br>    name<br>    email<br>  }<br>}<br><\/code><\/pre>\n\n\n\n<p>\uc774 \ubba4\ud14c\uc774\uc158\uc740 \uc0c8\ub85c\uc6b4 \uc0ac\uc6a9\uc790\ub97c \ucd94\uac00\ud558\uace0, \ucd94\uac00\ub41c \uc0ac\uc6a9\uc790\uc758 <code>id<\/code>, <code>name<\/code>, <code>email<\/code>\uc744 \ubc18\ud658\ud569\ub2c8\ub2e4. REST API\uc758 POST \uc694\uccad\uacfc \ube44\uc2b7\ud55c \uae30\ub2a5\uc744 \ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\ub370\uc774\ud130 \uc218\uc815\ud558\uae30<\/strong><\/h4>\n\n\n\n<p>\uc774\ubc88\uc5d0\ub294 \uc0ac\uc6a9\uc790\uc758 \uc815\ubcf4\ub97c <strong>\uc218\uc815<\/strong>\ud558\ub294 \ubba4\ud14c\uc774\uc158 \uc608\uc81c\uc785\ub2c8\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mutation {<br>  updateUser(id: 1, name: \"Bob\", email: \"bob@example.com\") {<br>    id<br>    name<br>    email<br>  }<br>}<br><\/code><\/pre>\n\n\n\n<p>\uc774 \uc608\uc2dc\ub294 <code>id<\/code>\uac00 1\uc778 \uc0ac\uc6a9\uc790\uc758 \uc774\ub984\uacfc \uc774\uba54\uc77c\uc744 \ubcc0\uacbd\ud558\ub294 \uc791\uc5c5\uc785\ub2c8\ub2e4. \uc11c\ubc84\ub294 \uc218\uc815\ub41c \uc0ac\uc6a9\uc790 \uc815\ubcf4\ub97c \ubc18\ud658\ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\ub370\uc774\ud130 \uc0ad\uc81c\ud558\uae30<\/strong><\/h4>\n\n\n\n<p>\ub9c8\uc9c0\ub9c9\uc73c\ub85c \ub370\uc774\ud130\ub97c <strong>\uc0ad\uc81c<\/strong>\ud558\ub294 \ubba4\ud14c\uc774\uc158\uc744 \ubcf4\uaca0\uc2b5\ub2c8\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mutation {<br>  deleteUser(id: 1) {<br>    id<br>  }<br>}<br><\/code><\/pre>\n\n\n\n<p>\uc774 \ubba4\ud14c\uc774\uc158\uc740 <code>id<\/code>\uac00 1\uc778 \uc0ac\uc6a9\uc790\ub97c \uc0ad\uc81c\ud558\uace0, \uc0ad\uc81c\ub41c \uc0ac\uc6a9\uc790\uc758 <code>id<\/code>\ub97c \ubc18\ud658\ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. \ucffc\ub9ac\uc640 \ubba4\ud14c\uc774\uc158\uc758 \ucc28\uc774\uc810 \uc815\ub9ac<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\ucffc\ub9ac(Query)<\/strong>: \uc11c\ubc84\uc5d0\uc11c \ub370\uc774\ud130\ub97c <strong>\uac00\uc838\uc624\ub294<\/strong> \uc791\uc5c5\uc785\ub2c8\ub2e4. \ud074\ub77c\uc774\uc5b8\ud2b8\uac00 \ud544\uc694\ud55c \ub370\uc774\ud130\ub97c \uc815\ud655\ud558\uac8c \uc694\uccad\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/li>\n\n\n\n<li><strong>\ubba4\ud14c\uc774\uc158(Mutation)<\/strong>: \uc11c\ubc84\uc5d0\uc11c \ub370\uc774\ud130\ub97c <strong>\ubcc0\uacbd<\/strong>\ud558\ub294 \uc791\uc5c5\uc785\ub2c8\ub2e4. \ub370\uc774\ud130\ub97c \ucd94\uac00, \uc218\uc815, \uc0ad\uc81c\ud558\ub294 \uc694\uccad\uc744 \ubcf4\ub0bc \ub54c \uc0ac\uc6a9\ub429\ub2c8\ub2e4.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>1. \ucffc\ub9ac(Query) \uc791\uc131\ud558\uae30 \ucffc\ub9ac\ub780 \ubb34\uc5c7\uc778\uac00? GraphQL\uc5d0\uc11c \ucffc\ub9ac\ub294 \uc11c\ubc84\ub85c\ubd80\ud130 \ub370\uc774\ud130\ub97c \uc694\uccad\ud558\ub294 \uc791\uc5c5\uc744 \uc758\ubbf8\ud569\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4, REST API\uc5d0\uc11c \ub370\uc774\ud130\ub97c \uac00\uc838\uc624\ub294 GET \uc694\uccad\uacfc \ube44\uc2b7\ud55c \uac1c\ub150\uc774\uc5d0\uc694. GraphQL \ucffc\ub9ac\uc758 \uac00\uc7a5 \ud070 \uc7a5\uc810\uc740 \ud544\uc694\ud55c \ub370\uc774\ud130\ub9cc \uc815\ud655\ud558\uac8c \uc694\uccad\ud560 \uc218 \uc788\ub2e4\ub294 \uac83\uc785\ub2c8\ub2e4. \uae30\ubcf8 \ucffc\ub9ac \uc608\uc81c \uc0ac\uc6a9\uc790 \uc815\ubcf4\ub97c \uc694\uccad\ud558\ub294 \ucffc\ub9ac\ub97c \uc608\uc2dc\ub85c \ub4e4\uc5b4\ubcfc\uac8c\uc694. \uc774 \uc608\uc2dc\ub294 \uc0ac\uc6a9\uc790\uc758 name\uacfc email \uc815\ubcf4\ub97c \uac00\uc838\uc624\ub294 \ucffc\ub9ac\uc785\ub2c8\ub2e4. query { user(id: 1) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55],"tags":[],"class_list":["post-1989","post","type-post","status-publish","format-standard","hentry","category-coding"],"_links":{"self":[{"href":"https:\/\/hyunsu.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1989","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hyunsu.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hyunsu.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hyunsu.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hyunsu.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1989"}],"version-history":[{"count":2,"href":"https:\/\/hyunsu.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1989\/revisions"}],"predecessor-version":[{"id":1991,"href":"https:\/\/hyunsu.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1989\/revisions\/1991"}],"wp:attachment":[{"href":"https:\/\/hyunsu.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hyunsu.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1989"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hyunsu.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}