{"id":285991,"date":"2017-05-06T11:20:03","date_gmt":"2017-05-06T07:20:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=285991"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=285991","title":{"rendered":"\u0414\u0435\u043b\u0430\u0435\u043c GraphQL API \u043d\u0430 PHP \u0438 MySQL"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/0bc\/8d1\/715\/0bc8d171582548d690cb776d7fb2ae8c.png\" alt=\"image\"\/><\/p>\n<p>  \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u044f \u0432\u0441\u0435 \u0447\u0430\u0449\u0435 \u0438 \u0447\u0430\u0449\u0435 \u0441\u043b\u044b\u0448\u0443 \u043f\u0440\u043e GraphQL. \u0418 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0435\u043c\u0430\u043b\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 GraphQL \u0441\u0435\u0440\u0432\u0435\u0440. \u041d\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u043e \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u044d\u043a\u0435\u043d\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Node.js.<\/p>\n<p>  \u042f \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0438\u043c\u0435\u044e \u043f\u0440\u043e\u0442\u0438\u0432 Node.js \u0438 \u0441\u0430\u043c \u0441 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0435\u0433\u043e, \u043d\u043e \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u044f \u0434\u0435\u043b\u0430\u044e \u043d\u0430 PHP. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0441 PHP \u0438 MySQL \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0434\u0435\u0448\u0435\u0432\u043b\u0435 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0435\u0435 \u0447\u0435\u043c \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0441 Node.js. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u044b\u043c \u0442\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 GraphQL \u043d\u0430 PHP \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0442 \u043d\u0438 \u0441\u043b\u043e\u0432\u0430.<\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 GraphQL \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 PHP \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/github.com\/webonyx\/graphql-php\">graphql-php<\/a> \u0438 \u043a\u0430\u043a \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 API \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 MySQL.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u042f \u0440\u0435\u0448\u0438\u043b \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e PHP \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u0435\u0435 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f \u0432\u0430\u043c \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0442\u0440\u0443\u0434\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u0438 \u0437\u043d\u0430\u043d\u0438\u044f \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u0422\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 <a href=\"https:\/\/github.com\/chentsulin\/awesome-graphql#lib-php\">\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/a> \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 graphql-php, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0442 \u0432\u0430\u0448\u0443 \u0440\u0430\u0431\u043e\u0442\u0443.<\/p>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/h2>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0434\u0435\u043b\u0430\u0442\u044c \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a GraphQL \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c GraphiQL-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430.<\/p>\n<p>  \u0414\u043b\u044f Chrome \u044d\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c:  <\/p>\n<ul>\n<li><a href=\"https:\/\/chrome.google.com\/webstore\/detail\/chromeiql\/fkkiamalmpiidkljmicmjfbieiclmeij\">ChromeiQL<\/a><\/li>\n<li><a href=\"https:\/\/chrome.google.com\/webstore\/detail\/graphiql-feen\/mcbfdonlkfpbfdpimkjilhdneikhfklp\">GraphiQL Feen<\/a><\/li>\n<\/ul>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0411\u0414 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u00abusers\u00bb \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/532\/d35\/ff3\/532d35ff3a0d4275956d450bac813d64.png\" alt=\"image\"\/><\/p>\n<p>  \u0410 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u00abfriendships\u00bb \u0441\u0432\u044f\u0437\u0438 \u0442\u0438\u043f\u0430 \u00ab\u043c\u043d\u043e\u0433\u0438\u0435-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u0434\u0440\u0443\u0436\u0431\u0443 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/c64\/227\/a03\/c64227a036ef47bebc6e4eaab5ff4706.png\" alt=\"image\"\/><\/p>\n<p>  \u0414\u0430\u043c\u043f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u0430\u043a \u0438 \u0432\u0435\u0441\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u0434, \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0438\u0437 <a href=\"https:\/\/github.com\/XAHTEP26\/graphql-php-tutorial\/tree\/master\/get-data-from-mysql\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 Github<\/a>.<\/p>\n<h2>Hello, GraphQL!<\/h2>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <a href=\"https:\/\/github.com\/webonyx\/graphql-php\">graphql-php<\/a> \u0432 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442. \u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e composer:<\/p>\n<p>  <code>composer require webonyx\/graphql-php<\/code><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u043e \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u00abHello, World\u00bb.<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043a\u043e\u0440\u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b graphql.php, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 (endpoint) \u043d\u0430\u0448\u0435\u0433\u043e GraphQL \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>  \u0412 \u043d\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0430\u0432\u0442\u043e\u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a composer:<\/p>\n<pre><code class=\"php\">require_once __DIR__ . '\/vendor\/autoload.php';<\/code><\/pre>\n<p>  \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c GraphQL:<\/p>\n<pre><code class=\"php\">use GraphQL\\GraphQL;<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c GraphQL \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u043c\u0443 \u0441\u0430\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u0441\u0445\u0435\u043c\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"php\">$rawInput = file_get_contents('php:\/\/input'); $input = json_decode($rawInput, true); $query = $input['query'];<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c GraphQL\\Schema:<\/p>\n<pre><code class=\"php\">use GraphQL\\Schema;<\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0441\u0445\u0435\u043c\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u043d \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 Query, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0430\u0448\u0435\u0433\u043e API, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u044d\u0442\u043e\u0442 \u0442\u0438\u043f.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\"><i>\u0422\u0430\u043a\u0436\u0435 \u0441\u0445\u0435\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 Mutation, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 API \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u044b \u0435\u0433\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c.<\/i>  <\/div>\n<\/div>\n<p>  \u0412 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 Query \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430 ObjectType, \u0430 \u0435\u0433\u043e \u043f\u043e\u043b\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 int \u0438\u043b\u0438 string), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u044d\u0442\u0438 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 GraphQL:<\/p>\n<pre><code class=\"php\">use GraphQL\\Type\\Definition\\Type; use GraphQL\\Type\\Definition\\ObjectType;<\/code><\/pre>\n<p>  \u0418 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 Query:<\/p>\n<pre><code class=\"php\">$queryType = new ObjectType([     'name' =&gt; 'Query',     'fields' =&gt; [         'hello' =&gt; [             'type' =&gt; Type::string(),             'description' =&gt; '\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435',             'resolve' =&gt; function () {                 return '\u041f\u0440\u0438\u0432\u0435\u0442, GraphQL!';             }         ]     ] ]);<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0438\u043c\u044f (name) \u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u043b\u0435\u0439 (fields), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 (description).<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\"><i>\u0422\u0430\u043a\u0436\u0435 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u00abinterfaces\u00bb, \u00abisTypeOf\u00bb \u0438 \u00abresolveField\u00bb, \u043d\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u044b \u0438\u0445 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c.<\/i>  <\/div>\n<\/div>\n<p>  \u041f\u043e\u043b\u044f \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u00abname\u00bb \u0438 \u00abtype\u00bb. \u0415\u0441\u043b\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u00abname\u00bb \u043d\u0435 \u0437\u0430\u0434\u0430\u043d\u043e, \u0442\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043c\u0435\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043b\u044e\u0447 \u043f\u043e\u043b\u044f (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u00abhello\u00bb). \u0422\u0430\u043a\u0436\u0435 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0443 \u043f\u043e\u043b\u044f \u00abhello\u00bb \u0437\u0430\u0434\u0430\u043d\u044b \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u00abdescription\u00bb \u2014 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u00abresolve\u00bb \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0430\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u00abresolve\u00bb \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 &quot;<i>\u041f\u0440\u0438\u0432\u0435\u0442, GraphQL!<\/i>&quot;, \u043d\u043e \u0432 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u043b\u0438\u0431\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e API \u0438\u043b\u0438 \u0438\u0437 \u0411\u0414 \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0435\u0435.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\"><i>\u0422\u0430\u043a\u0436\u0435 \u043f\u043e\u043b\u044f \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e args, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u0437\u0436\u0435, \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e deprecationReason, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f.<\/i>  <\/div>\n<\/div>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u00abQuery\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e \u043f\u043e\u043b\u0435 \u00abhello\u00bb, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0442\u0435\u043a\u0441\u0442\u0430. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432 \u0441\u0445\u0435\u043c\u0443 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"php\">$schema = new Schema([     'query' =&gt; $queryType ]);<\/code><\/pre>\n<p>  \u0410 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441 GraphQL \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430:<\/p>\n<pre><code class=\"php\">$result = GraphQL::execute($schema, $query);<\/code><\/pre>\n<p>  \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0432\u0438\u0434\u0435 JSON \u0438 \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0433\u043e\u0442\u043e\u0432\u043e:<\/p>\n<pre><code class=\"php\">header('Content-Type: application\/json; charset=UTF-8'); echo json_encode($result);<\/code><\/pre>\n<p>  \u041e\u0431\u0435\u0440\u043d\u0435\u043c \u043a\u043e\u0434 \u0432 \u0431\u043b\u043e\u043a try-catch, \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043a\u043e\u0434 \u0444\u0430\u0439\u043b\u0430 graphql.php \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">require_once __DIR__ . '\/vendor\/autoload.php';  use GraphQL\\GraphQL; use GraphQL\\Schema; use GraphQL\\Type\\Definition\\Type; use GraphQL\\Type\\Definition\\ObjectType;  try {     \/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430     $rawInput = file_get_contents('php:\/\/input');     $input = json_decode($rawInput, true);     $query = $input['query'];      \/\/ \u0421\u043e\u0434\u0430\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 &quot;\u0417\u0430\u043f\u0440\u043e\u0441&quot;     $queryType = new ObjectType([         'name' =&gt; 'Query',         'fields' =&gt; [             'hello' =&gt; [                 'type' =&gt; Type::string(),                 'description' =&gt; '\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435',                 'resolve' =&gt; function () {                     return '\u041f\u0440\u0438\u0432\u0435\u0442, GraphQL!';                 }             ]         ]     ]);      \/\/ \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0445\u0435\u043c\u044b     $schema = new Schema([         'query' =&gt; $queryType     ]);      \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430     $result = GraphQL::execute($schema, $query); } catch (\\Exception $e) {     $result = [         'error' =&gt; [             'message' =&gt; $e-&gt;getMessage()         ]     ]; }  \/\/ \u0412\u044b\u0432\u043e\u0434 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 header('Content-Type: application\/json; charset=UTF-8'); echo json_encode($result);<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0443 GraphQL. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f GraphiQL, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c endpoint (\u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u00ab<a href=\"http:\/\/localhost\/graphql.php\">localhost\/graphql.php<\/a>\u00bb) \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/77e\/f44\/80b\/77ef4480bf534f05bf88d482b5310ab6.png\" alt=\"image\"\/><\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u0437 \u0411\u0414<\/h2>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443. \u0412\u044b\u0432\u0435\u0434\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 MySQL.<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430 ObjectType. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043d\u0430\u0433\u0440\u043e\u043c\u043e\u0436\u0434\u0430\u0442\u044c \u043a\u043e\u0434 \u0432 graphql.php, \u0432\u044b\u043d\u0435\u0441\u0435\u043c \u0432\u0441\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. \u0410 \u0447\u0442\u043e\u0431\u044b \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0430\u043c\u0438\u0445 \u0441\u0435\u0431\u044f, \u043e\u0444\u043e\u0440\u043c\u0438\u043c \u0438\u0445 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u0432 \u0442\u0438\u043f\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u00abuser\u00bb \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u00abfriends\u00bb, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0442\u0430\u043a\u043e\u0433\u043e \u0436\u0435 \u0442\u0438\u043f\u0430 \u00abuser\u00bb.<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043e\u0444\u043e\u0440\u043c\u043b\u044f\u0435\u043c \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u0442\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0443 \u043d\u0435\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u00abname\u00bb, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0443 \u043a\u043b\u0430\u0441\u0441\u0430 QueryType \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u044f Query).<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 Query, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0432 graphql.php:<\/p>\n<pre><code class=\"php\">$queryType = new ObjectType([     'name' =&gt; 'Query',     'fields' =&gt; [         'hello' =&gt; [             'type' =&gt; Type::string(),             'description' =&gt; '\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435',             'resolve' =&gt; function () {                 return '\u041f\u0440\u0438\u0432\u0435\u0442, GraphQL!';             }         ]     ] ]);<\/code><\/pre>\n<p>  \u0411\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 QueryType.php \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">class QueryType extends ObjectType {     public function __construct()     {         $config = [             'fields' =&gt; [                 'hello' =&gt; [                     'type' =&gt; Type::string(),                     'description' =&gt; '\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435',                     'resolve' =&gt; function () {                         return '\u041f\u0440\u0438\u0432\u0435\u0442, GraphQL!';                     }                 ]             ]         ];         parent::__construct($config);     } }<\/code><\/pre>\n<p>  \u0410 \u0447\u0442\u043e\u0431\u044b \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0442\u0438\u043f\u043e\u0432, \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 \u00abfields\u00bb \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u043b\u0435\u0439, \u0430 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0443\u044e \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u043b\u0435\u0439:<\/p>\n<pre><code class=\"php\">class QueryType extends ObjectType {     public function __construct()     {         $config = [             'fields' =&gt;  function() {                 return [                     'hello' =&gt; [                         'type' =&gt; Type::string(),                         'description' =&gt; '\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435',                         'resolve' =&gt; function () {                             return '\u041f\u0440\u0438\u0432\u0435\u0442, GraphQL!';                         }                     ]                 ];             }         ];         parent::__construct($config);     } }<\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043d\u0438\u0445 \u043b\u0443\u0447\u0448\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0435\u0441\u0442\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u0444\u0430\u0431\u0440\u0438\u043a\u043e\u0439 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 App, \u0430 \u0432 \u043d\u0435\u0439 \u0444\u0430\u0439\u043b, Types.php, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0440\u0435\u0435\u0441\u0442\u0440\u043e\u043c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0432 \u043f\u0430\u043f\u043a\u0435 App \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u043e\u0434\u043f\u0430\u043f\u043a\u0443 Type, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u0432 \u043d\u0435\u0435 QueryType.php.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0435\u043d \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0440\u0435\u0435\u0441\u0442\u0440 Types.php \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438:<\/p>\n<pre><code class=\"php\">namespace App;  use App\\Type\\QueryType; use GraphQL\\Type\\Definition\\Type;  class Types {     private static $query;      public static function query()     {         return self::$query ?: (self::$query = new QueryType());     }      public static function string()     {         return Type::string();     } }<\/code><\/pre>\n<p>  \u041f\u043e\u043a\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c \u0440\u0435\u0435\u0441\u0442\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0435\u0433\u043e 2 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445: 1 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 (string) \u0438 1 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 (query).<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043e \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445 \u0432\u043c\u0435\u0441\u0442\u043e:<\/p>\n<pre><code class=\"php\">use GraphQL\\Type\\Definition\\Type;<\/code><\/pre>\n<p>  \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u043d\u0430\u0448 \u0440\u0435\u0435\u0441\u0442\u0440 \u0442\u0438\u043f\u043e\u0432:<\/p>\n<pre><code class=\"php\">use App\\Types;<\/code><\/pre>\n<p>  \u0418 \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0432\u0441\u0435 \u0440\u0430\u043d\u0435\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u043d\u0430 \u0442\u0438\u043f\u044b \u0438\u0437 \u0440\u0435\u0435\u0441\u0442\u0440\u0430.<\/p>\n<p>  \u0412 QueryType.php \u0432\u043c\u0435\u0441\u0442\u043e:<\/p>\n<pre><code class=\"php\">Type::string()<\/code><\/pre>\n<p>  \u0411\u0443\u0434\u0435\u0442:<\/p>\n<pre><code class=\"php\">Types::string()<\/code><\/pre>\n<p>  \u0410 \u0441\u0445\u0435\u043c\u0430 \u0432 graphql.php \u0442\u0435\u043f\u0435\u0440\u044c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">$schema = new Schema([     'query' =&gt; Types::query() ]);<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0435\u0439. \u041f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0431\u0430\u0437\u044b \u043c\u043e\u0436\u043d\u043e \u043b\u044e\u0431\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c. \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b. \u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043a MySQL \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432 \u043d\u0435\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u044b. \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a GraphQL, \u0442\u043e \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0435\u0433\u043e \u043a\u043e\u0434:<\/p>\n<pre><code class=\"php\">namespace App;  class DB {     private static $pdo;          public static function init($config)     {         self::$pdo = new PDO(&quot;mysql:host={$config['host']};dbname={$config['database']}&quot;, $config['username'], $config['password']);         self::$pdo-&gt;setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);     }          public static function selectOne($query)     {         $records = self::select($query);         return array_shift($records);     }          public static function select($query)     {         $statement = self::$pdo-&gt;query($query);         return $statement-&gt;fetchAll();     }          public static function affectingStatement($query)     {         $statement = self::$pdo-&gt;query($query);         return $statement-&gt;rowCount();     } }<\/code><\/pre>\n<p>  \u0412 \u0444\u0430\u0439\u043b\u0435 graphql.php \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u0434 \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0411\u0414:<\/p>\n<pre><code class=\"php\">\/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0411\u0414 $config = [     'host' =&gt; 'localhost',     'database' =&gt; 'gql',     'username' =&gt; 'root',     'password' =&gt; 'root' ];  \/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0411\u0414 DB::init($config);<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u043f\u0430\u043f\u043a\u0435 Type \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 User, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435. \u041a\u043e\u0434 \u0444\u0430\u0439\u043b\u0430 UserType.php \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438\u043c:<\/p>\n<pre><code class=\"php\">namespace App\\Type;  use App\\DB; use App\\Types; use GraphQL\\Type\\Definition\\ObjectType;  class UserType extends ObjectType {     public function __construct()     {         $config = [             'description' =&gt; '\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c',             'fields' =&gt; function() {                 return [                     'id' =&gt; [                         'type' =&gt; Types::string(),                         'description' =&gt; '\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f'                     ],                     'name' =&gt; [                         'type' =&gt; Types::string(),                         'description' =&gt; '\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f'                     ],                     'email' =&gt; [                         'type' =&gt; Types::string(),                         'description' =&gt; 'E-mail \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f'                     ],                     'friends' =&gt; [                         'type' =&gt; Types::listOf(Types::user()),                         'description' =&gt; '\u0414\u0440\u0443\u0437\u044c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f',                         'resolve' =&gt; function ($root) {                             return DB::select(&quot;SELECT u.* from friendships f JOIN users u ON u.id = f.friend_id WHERE f.user_id = {$root-&gt;id}&quot;);                         }                     ],                     'countFriends' =&gt; [                         'type' =&gt; Types::int(),                         'description' =&gt; '\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0440\u0443\u0437\u0435\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f',                         'resolve' =&gt; function ($root) {                             return DB::affectingStatement(&quot;SELECT u.* from friendships f JOIN users u ON u.id = f.friend_id WHERE f.user_id = {$root-&gt;id}&quot;);                         }                     ]                 ];             }         ];         parent::__construct($config);     } }<\/code><\/pre>\n<p>  \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u0438\u0437 \u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u00abdescription\u00bb. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u00abid\u00bb, \u00abname\u00bb, \u00abemail\u00bb \u0438 \u00abcountFriends\u00bb \u0438\u043c\u0435\u044e\u0442 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0442\u0438\u043f\u044b, \u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u00abfriends\u00bb \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0434\u0440\u0443\u0437\u0435\u0439 \u2013 \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f:<\/p>\n<pre><code class=\"php\">Types::listOf(Types::user())<\/code><\/pre>\n<p>  \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0430\u0448 \u0440\u0435\u0435\u0441\u0442\u0440 \u043f\u0430\u0440\u0443 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0440\u0430\u043d\u044c\u0448\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438:<\/p>\n<pre><code class=\"php\">public static function int() {     return Type::int(); }  public static function listOf($type) {     return Type::listOf($type); }<\/code><\/pre>\n<p>  \u0418 \u0442\u043e\u043b\u044c\u043a\u043e, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0438 \u0442\u0438\u043f User:<\/p>\n<pre><code class=\"php\">private static $user;  public static function user() {     return self::$user ?: (self::$user = new UserType()); }<\/code><\/pre>\n<p>  \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (resolve) \u0434\u043b\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u00abfriends\u00bb \u0438 \u00abcountFriends\u00bb \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0410\u043d\u043e\u043d\u0438\u043c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432 \u00abresolve\u00bb \u043f\u0435\u0440\u0432\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044f ($root), \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c id \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0435\u0433\u043e \u0432 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u0440\u0443\u0437\u0435\u0439.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\"><i>\u042f \u043d\u0435 \u0443\u0434\u0435\u043b\u044f\u043b \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043f\u043e\u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0432 \u0443\u0447\u0435\u0431\u043d\u044b\u0445 \u0446\u0435\u043b\u044f\u0445, \u043d\u043e \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0435\u043b\u044c\u0437\u044f.<\/i>  <\/div>\n<\/div>\n<p>  \u0412 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043a\u043e\u0434 QueryType.php \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432 API \u0431\u044b\u043b\u0438 \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435 \u043f\u043e \u0435\u0433\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443 (\u043f\u043e\u043b\u0435 \u00abuser\u00bb), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 (\u043f\u043e\u043b\u0435 \u00aballUsers\u00bb):<\/p>\n<pre><code class=\"php\">namespace App\\Type;  use App\\DB; use App\\Types; use GraphQL\\Type\\Definition\\ObjectType;  class QueryType extends ObjectType {     public function __construct()     {         $config = [             'fields' =&gt; function() {                 return [                     'user' =&gt; [                         'type' =&gt; Types::user(),                         'description' =&gt; '\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e id',                         'args' =&gt; [                             'id' =&gt; Types::int()                         ],                         'resolve' =&gt; function ($root, $args) {                             return DB::selectOne(&quot;SELECT * from users WHERE id = {$args['id']}&quot;);                         }                     ],                     'allUsers' =&gt; [                         'type' =&gt; Types::listOf(Types::user()),                         'description' =&gt; '\u0421\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439',                         'resolve' =&gt; function () {                             return DB::select('SELECT * from users');                         }                     ]                 ];             }         ];         parent::__construct($config);     } }<\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u0447\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u0443 \u043f\u043e\u043b\u044f \u00abuser\u00bb \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u00abargs\u00bb, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041c\u0430\u0441\u0441\u0438\u0432 \u00abargs\u00bb \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u00abresolve\u00bb \u0432\u0442\u043e\u0440\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0443\u0437\u043d\u0430\u0435\u043c id \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\"><i>\u0423 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u0437\u0430\u043f\u0438\u0441\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043a\u043b\u044e\u0447\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u0430\u043c\u0438, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u2013 \u0442\u0438\u043f\u0430\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432:<\/i>  <\/p>\n<pre><code class=\"php\">'args' =&gt; [     'id' =&gt; Types::int() ]<\/code><\/pre>\n<p>  <i>\u0412\u043c\u0435\u0441\u0442\u043e:<\/i>  <\/p>\n<pre><code class=\"php\">'args' =&gt; [     'id' =&gt; [         'type' =&gt; Types::int()     ] ]<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 GraphQL \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0443 \u0442\u0430\u043a\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/421\/d7e\/8f0\/421d7e8f01c246cf8ae69fa15dd02df5.png\" alt=\"image\"\/><\/p>\n<p>  \u0418\u043b\u0438 \u0442\u0430\u043a\u0438\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/5e0\/0e5\/144\/5e00e51444334aa5bd5a869abc93fe89.png\" alt=\"image\"\/><\/p>\n<p>  \u0418\u043b\u0438 \u043b\u044e\u0431\u044b\u043c \u0434\u0440\u0443\u0433\u0438\u043c.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435. \u0427\u0438\u0442\u0430\u0439\u0442\u0435 <a href=\"http:\/\/webonyx.github.io\/graphql-php\/\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/a>. \u0417\u0430\u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445. \u041a\u0440\u0438\u0442\u0438\u043a\u0443\u0439\u0442\u0435.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043d\u0435, \u0442\u043e \u044f \u043d\u0430\u043f\u0438\u0448\u0443 \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e GraphQL \u043d\u0430 PHP, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u043e\u0448\u0435\u043b \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/github.com\/XAHTEP26\/graphql-php-tutorial\/tree\/master\/get-data-from-mysql\">\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438 \u043d\u0430 Github<\/a>.<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/328122\/\"> https:\/\/habrahabr.ru\/post\/328122\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/0bc\/8d1\/715\/0bc8d171582548d690cb776d7fb2ae8c.png\" alt=\"image\"\/><\/p>\n<p>  \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u044f \u0432\u0441\u0435 \u0447\u0430\u0449\u0435 \u0438 \u0447\u0430\u0449\u0435 \u0441\u043b\u044b\u0448\u0443 \u043f\u0440\u043e GraphQL. \u0418 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0435\u043c\u0430\u043b\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 GraphQL \u0441\u0435\u0440\u0432\u0435\u0440. \u041d\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u043e \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u044d\u043a\u0435\u043d\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Node.js.<\/p>\n<p>  \u042f \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0438\u043c\u0435\u044e \u043f\u0440\u043e\u0442\u0438\u0432 Node.js \u0438 \u0441\u0430\u043c \u0441 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0435\u0433\u043e, \u043d\u043e \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u044f \u0434\u0435\u043b\u0430\u044e \u043d\u0430 PHP. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0441 PHP \u0438 MySQL \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0434\u0435\u0448\u0435\u0432\u043b\u0435 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0435\u0435 \u0447\u0435\u043c \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0441 Node.js. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u044b\u043c \u0442\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 GraphQL \u043d\u0430 PHP \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0442 \u043d\u0438 \u0441\u043b\u043e\u0432\u0430.<\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 GraphQL \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 PHP \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/github.com\/webonyx\/graphql-php\">graphql-php<\/a> \u0438 \u043a\u0430\u043a \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 API \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 MySQL.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-285991","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/285991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=285991"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/285991\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=285991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=285991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=285991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}