{"id":362817,"date":"2024-05-21T01:42:52","date_gmt":"2024-05-21T01:42:52","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=362817"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=362817","title":{"rendered":"<span>\u041a\u0430\u043a \u043c\u044b \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0443 \u0431\u043b\u044e\u0434 c \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u043d\u0433\u0440\u0435\u0434\u0438\u0435\u043d\u0442\u0430: GraphQL<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u041d\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0435, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0435\u0447\u0435\u0433\u043e \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0434\u043e\u043c\u0430 \u043e\u0434\u043d\u0430 \u043a\u0430\u0440\u0442\u043e\u0448\u043a\u0430. \u041f\u0440\u0438 \u0441\u043c\u0435\u043a\u0430\u043b\u043a\u0435 \u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043f\u0435\u0446\u0438\u0439 \u2014 \u043f\u044e\u0440\u0435, \u0434\u0440\u0430\u043d\u0438\u043a\u0438, \u0437\u0430\u043f\u0435\u043a\u0430\u043d\u043a\u0430, \u0447\u0438\u043f\u0441\u044b \u0444\u0440\u0438&#8230; \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u044b \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u0435\u043c \u043d\u0435 \u043a\u0443\u043b\u0438\u043d\u0430\u0440\u0438\u044e. \u041c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e GraphQL \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0444\u0438\u0447\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0432\u043d\u0435\u0434\u0440\u0438\u043b\u0438 \u0443 \u0441\u0435\u0431\u044f \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438, \u0438 \u0442\u0438\u0440\u0430\u0436\u0438\u0440\u0443\u0435\u043c \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b, \u0433\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u044d\u0442\u043e\u0442 \u044f\u0437\u044b\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0438 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438 GraphQL \u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440\u0430\u043c, \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0442\u043e\u0440\u0430\u043c, \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u043c \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u00ab\u043a\u043e\u0434\u0430\u00bb, \u0430 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442 \u043f\u043e\u043b\u043d\u044b\u0439 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443, \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435, \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u0438 \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/329\/9f4\/284\/3299f428498dddb295d9f1a7017dd3ce.png\" width=\"904\" height=\"510\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/329\/9f4\/284\/3299f428498dddb295d9f1a7017dd3ce.png\"\/><\/figure>\n<h2>GraphQL: \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0438 \u0441\u043e\u0432\u0435\u0442\u044b<\/h2>\n<p>GraphQL \u2014 \u044d\u0442\u043e \u044f\u0437\u044b\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c.<\/p>\n<p>\u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u044f\u0437\u044b\u043a\u0430:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0442\u043e\u0447\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0435\u043c\u0443 \u043d\u0443\u0436\u043d\u044b;<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0442\u0438\u043f\u043e\u0432 \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/91a\/fef\/13f\/91afef13fded9b75d98ad6dc2cf6d34b.png\" width=\"904\" height=\"496\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/91a\/fef\/13f\/91afef13fded9b75d98ad6dc2cf6d34b.png\"\/><\/figure>\n<p>\u041d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0432\u044b\u0448\u0435 \u0443\u043a\u0430\u0437\u0430\u043d \u0433\u0440\u0430\u0444, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u0442\u0438\u043f\u043e\u0432: users, rubrics, news, comment. \u041d\u043e \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0435\u0439, \u0431\u043e\u043b\u0435\u0435 10-\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043e\u043f\u0438\u0441\u0430\u0432 \u0447\u0435\u0442\u044b\u0440\u0435 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0432\u0430\u0440\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u044b \u043c\u044b \u0441\u0442\u0430\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/webonyx\/graphql-php\">\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u043f\u043b\u043e\u0445\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u043e\u0441\u0442\u0440\u044f\u0442\u044c \u043d\u0430 \u044d\u0442\u043e\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c.<\/p>\n<p>\u0417\u0430 \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0441\u0432\u043e\u0438 must have \u043f\u0440\u0430\u0432\u0438\u043b\u0430\/\u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0442\u0438\u0440\u0430\u0436\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043d\u0438\u0445.<\/p>\n<p><strong><em>\u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043a\u043e\u0434,<\/em><\/strong> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043d\u0438\u0436\u0435:<\/p>\n<ul>\n<li>\n<p>\u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c PHP \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u043e\u0431\u0440\u0430\u0442\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u0445\u043e\u0434\u043d\u044b\u0445\/\u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0442.\u0434.;<\/p>\n<\/li>\n<li>\n<p><strong><em>\u043d\u043e\u0441\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440 \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f\/\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430;<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p>\u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0432 \u0447\u0438\u0441\u0442\u043e\u043c \u0432\u0438\u0434\u0435.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/h2>\n<p>\u0412 GraphQL \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u0445 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<p><strong>MutationType<\/strong> \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p><strong>QueryType<\/strong> \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p><strong>SubscriptionType <\/strong>\u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u043d\u043e \u043e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u00ab\u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445\u00bb \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a PHP \u0438\u043b\u0438 PHP > 8.1 (\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f <a href=\"https:\/\/github.com\/webonyx\/graphql-php\">\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/a>). \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \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. \u0423 \u0441\u0435\u0431\u044f \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u043e\u043a, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0448\u0438\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0431\u0440\u043e\u043a\u0435\u0440\u044b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438 \u0442.\u0434.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043d\u0438\u0436\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/590\/1de\/c76\/5901dec76ad5670a74c73e8601981634.png\" width=\"904\" height=\"448\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/590\/1de\/c76\/5901dec76ad5670a74c73e8601981634.png\"\/><\/figure>\n<p>\u0412\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b \/graphql\/index.php \u0441 \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c:<\/p>\n<pre><code class=\"php\">&lt;?php \/\/\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c GraphQL require_once realpath('..\/vendor\/autoload.php');  try {     \/\/\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435     $rawInput = file_get_contents('php:\/\/input');     $input = json_decode($rawInput, true);     $query = $input['query'];          \/\/\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0445\u0435\u043c\u0443     $schema = new Schema([         'query' => Types::query(),         'mutation' => Types::mutation()     ]);          \/\/\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441     $result = GraphQL::executeQuery($schema, $query);     $arException = $result->toArray()['errors'] ?: [];  \/\/\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0438 } catch (Throwable $e) {     $result = ['error' => ['message' => $e->getMessage()]]; } finally {     \/\/\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435     Log::push($query, $arException); }  \/\/\u0412\u044b\u0432\u043e\u0434\u0438\u043c \u043e\u0442\u0432\u0435\u0442 header('Content-Type: application\/json; charset=UTF-8'); echo json_encode($result);<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0442\u0438\u043f\u0430, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e:<\/p>\n<ul>\n<li>\n<p>\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e;<\/p>\n<\/li>\n<li>\n<p>\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 \u0442\u0438\u043f, \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043d\u0430 \u043d\u043e\u0432\u043e\u0441\u0442\u0438 (news) \u0438 \u0440\u0443\u0431\u0440\u0438\u043a\u0438 (rubrics). \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p><strong>\u041e\u043f\u0438\u0448\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 news:<\/strong><\/p>\n<pre><code class=\"php\">&lt;?php class QueryType extends ObjectType {     public function __construct()     {         $config = [             'fields' => function () {                 return [                     'news' => [ \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c query \u0437\u0430\u043f\u0440\u043e\u0441 news                         'type' => Types::news(), \/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445                         'args' => [                             'id' => Types::int(), \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u0432\u043e\u0441\u0442\u044c                         ],                         'resolve' => function ($root, $args, $context, $info) {                             return News::get($args); \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 get \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430                         }                     ]                 ];             }         ];         parent::__construct($config);     } }<\/code><\/pre>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 &#171;QueryType&#187; \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0432\u0441\u0435 \u043f\u043e\u0434\u0442\u0438\u043f\u044b &#171;query&#187; \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0438 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d \u043e\u0442 &#171;ObjectType&#187;, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u00a0\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0442\u0438\u043f news:<\/p>\n<pre><code class=\"php\">&lt;?php class Types extends Type {     private static $query;     private static $news;     private static $rubric;      public static function query()     {         return self::$query ?: (self::$query = new QueryType());     }      public static function news() \/\/ \u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f     {         return self::$news ?: (self::$news = new NewsType()); \/\/\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430     } } <\/code><\/pre>\n<p>\u041e\u043f\u0438\u0448\u0435\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u0442\u0438\u043f\u0430 news:<\/p>\n<pre><code class=\"php\">&lt;?php class NewsType extends ObjectType {     public function __construct()     {         $config = [             'fields' => function () {                 return [ \/\/\u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u043f\u043e\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0438\u0445 \u0442\u0438\u043f\u044b                     'id' => [                         'type' => Types::int(),\/\/id \u043d\u043e\u0432\u043e\u0441\u0442\u0438                     ],                     'name' => [                         'type' => Types::string(),\/\/\u0438\u043c\u044f \u043d\u043e\u0432\u043e\u0441\u0442\u0438                     ],                     'text' => [                         'type' => Types::string(),\/\/\u0442\u0435\u043a\u0441\u0442 \u043d\u043e\u0432\u043e\u0441\u0442\u0438                     ],                 ];             }         ];         parent::__construct($config);     } } <\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c:<\/p>\n<pre><code class=\"php\">&lt;?php namespace GraphQL\\App\\Type;  use GraphQL\\App\\DB\\ConnectDB;  class News {     public static function get($args)     {         $DB = new ConnectDB();         return $DB->query(\"SELECT * from news WHERE id = {$args['id']}\")[0];     } }<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0434\u0435\u043b\u0430\u0432 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u0448\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u0441\u043b\u0430\u0432 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0443\u043a\u0430\u0437\u0430\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0430\u0431\u043e\u0440 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/67f\/87f\/925\/67f87f9253b6315c974ca54f512eeb64.png\" width=\"904\" height=\"782\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/67f\/87f\/925\/67f87f9253b6315c974ca54f512eeb64.png\"\/><\/figure>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a GraphQL \u2013 \u044d\u0442\u043e \u0443\u043c\u043d\u044b\u0439 endpoint, \u0442\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u043f\u043e\u043b\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e id \u0438 name \u043d\u043e\u0432\u043e\u0441\u0442\u0438. \u0421\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0436\u0443, \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!) \u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u043d\u0438\u0436\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d63\/dfd\/7d6\/d63dfd7d6795bf26f5c032b12b239c09.png\" width=\"904\" height=\"676\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d63\/dfd\/7d6\/d63dfd7d6795bf26f5c032b12b239c09.png\"\/><\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0443\u0431\u0435\u0434\u0438\u043b\u0438\u0441\u044c, \u0447\u0442\u043e GraphQL \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u00ab\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044e\u00bb.<\/p>\n<p><strong>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c: \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 (One step)<\/strong><\/p>\n<p>\u041a\u0430\u043a \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u0440\u0430\u043d\u0435\u0435, \u043d\u043e\u0432\u043e\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438, \u0432 \u0442\u043e\u043c \u0438 \u0447\u0438\u0441\u043b\u0435 \u0438 \u0441 \u0440\u0443\u0431\u0440\u0438\u043a\u043e\u0439.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u043f\u0438\u0448\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0442\u0438\u043f\u0430 rubric, \u043e\u043d \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0442\u0438\u043f\u0430 news:<\/p>\n<pre><code class=\"php\">&lt;?php class QueryType extends ObjectType {     public function __construct()     {         $config = [             'fields' => function () {                 return [                     'news' => [\/*...*\/],                     'rubric' => [ \/\/\u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441                         'type' => Types::rubric(), \/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 - \u0440\u0443\u0431\u0440\u0438\u043a\u0430                         'args' => [                             'id' => Types::int(), \/\/ \u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0443\u0431\u0440\u0438\u043a\u0443                         ],                         'resolve' => function ($root, $args, $context, $info) {                             return Rubric::get($args); \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 get \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430                         }                     ]                 ];             }         ];         parent::__construct($config);     } } <\/code><\/pre>\n<p>\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e:<\/p>\n<pre><code class=\"php\">&lt;?php class Types extends Type {     private static $query;     private static $news;     private static $rubric;      public static function query()     {         return self::$query ?: (self::$query = new QueryType());     }      public static function news()     {         return self::$news ?: (self::$news = new NewsType());     }      public static function rubric() \/\/ \u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f     {         return self::$rubric ?: (self::$rubric = new RubricType()); \/\/ \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430     } } <\/code><\/pre>\n<p>\u041e\u043f\u0438\u0448\u0435\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f:<\/p>\n<pre><code class=\"php\">&lt;?php class RubricType extends ObjectType {     public function __construct()     {         $config = [             'fields' => function () {                 return [ \/\/\u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u043f\u043e\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0438\u0445 \u0442\u0438\u043f\u044b                     'id' => [\/\/id \u0440\u0443\u0431\u0440\u0438\u043a\u0438                         'type' => Types::int(),                     ],                     'name' => [\/\/\u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0443\u0431\u0440\u0438\u043a\u0438                         'type' => Types::string(),                     ],                     'code' => [\/\/\u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0440\u0443\u0431\u0440\u0438\u043a\u0438                         'type' => Types::string(),                     ],                 ];             }         ];         parent::__construct($config);     } } <\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c:<\/p>\n<pre><code class=\"php\">&lt;?php  namespace GraphQL\\App\\Type;  use GraphQL\\App\\DB\\ConnectDB;  class Rubric {     public static function get($args)     {         $DB = new ConnectDB();         return $DB->query(\"SELECT * from rubrics WHERE id = {$args['id']}\")[0];     } }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043c \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u043e\u0441\u0442\u044c \u0441 \u0440\u0443\u0431\u0440\u0438\u043a\u043e\u0439, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0440\u0443\u0431\u0440\u0438\u043a\u0438:<\/p>\n<pre><code class=\"php\">&lt;?php  class NewsType extends ObjectType {     public function __construct()     {         $config = [             'fields' => function () {                 return [                     'id' => [                         'type' => Types::int(),                     ],                     'name' => [                         'type' => Types::string(),                     ],                     'text' => [                         'type' => Types::string(),                     ],                     'rubric' => [                         'type' => Types::Rubric(), \/\/\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0438\u043f \u0434\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 id \u0440\u0443\u0431\u0440\u0438\u043a                     ],                 ];             }         ];         parent::__construct($config);     } } <\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0430\u0448 query \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043b\u043e\u0432\u043e \u00abrubric\u00bb \u0438 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f id \u0440\u0443\u0431\u0440\u0438\u043a\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/276\/f64\/2ee\/276f642ee01f5877b583d5ba8842f2bf.png\" width=\"904\" height=\"784\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/276\/f64\/2ee\/276f642ee01f5877b583d5ba8842f2bf.png\"\/><\/figure>\n<p>\u041d\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u0441\u0430\u043c\u043e\u0439 \u0440\u0443\u0431\u0440\u0438\u043a\u0435, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0442.\u0435. \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e step-by-step.<\/p>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e \u0440\u0443\u0431\u0440\u0438\u043a\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c11\/215\/39c\/c1121539cd2eb2ce5b16865641f8cbe9.png\" width=\"904\" height=\"796\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c11\/215\/39c\/c1121539cd2eb2ce5b16865641f8cbe9.png\"\/><\/figure>\n<p>\u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043d\u043e \u0432 \u0434\u0432\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<ul>\n<li>\n<p>news ~ 159 ms <\/p>\n<\/li>\n<li>\n<p>rubric ~121 ms<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0442\u043e\u0433\u043e: ~280 ms<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b (\u0441\u0435\u0442\u044c\/\u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442, \u0430\u043d\u0430\u043b\u0438\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0438 \u0442.\u0434.).<\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043a\u043b\u0430\u0441\u0441 \u0441 \u043d\u043e\u0432\u043e\u0441\u0442\u044c\u044e \u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e 2-3 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0432 resolve \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"php\">&lt;?php  class NewsType extends ObjectType {     public function __construct()     {         $config = [             'fields' => function () {                 return [                     'id' => ['type' => Types::int()],                     'name' => ['type' => Types::string()],                     'text' => ['type' => Types::string()],                     'rubric' => [  \/\/\u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0443\u0431\u0440\u0438\u043a\u0438 \u043d\u043e\u0432\u043e\u0441\u0442\u0438                         'type' => Types::rubric(),                         \/\/\u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u043c\u0435\u0442\u043e\u0434 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u043e\u0442\u0431\u043e\u0440\u0430 \u0440\u0443\u0431\u0440\u0438\u043a \u043f\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u043c \u043f\u043e\u043b\u044f\u043c                         'resolve' => function ($root, $args, $context, $info) {                             return Rubric::get(['id' => $root['rubric']]);                         }                     ],                 ];             }         ];         parent::__construct($config);     } } <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441, \u0443\u043a\u0430\u0437\u0430\u0432 \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u0445 \u0432\u0441\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u0438 \u0440\u0443\u0431\u0440\u0438\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6a3\/63e\/1b9\/6a363e1b9e2c45486efc298aea792d9e.png\" width=\"904\" height=\"792\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6a3\/63e\/1b9\/6a363e1b9e2c45486efc298aea792d9e.png\"\/><\/figure>\n<p>\u041d\u0430\u043c \u0432\u0435\u0440\u043d\u0443\u043b\u0441\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u043f\u043e \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u0438 \u0440\u0443\u0431\u0440\u0438\u043a\u0435 \u0437\u0430 \u043e\u0434\u0438\u043d \u0448\u0430\u0433 (One step) \u0437\u0430<strong> <\/strong>~161 ms. \u041a\u0430\u043a \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u043f\u043e\u043b\u0435 rubric \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u043e\u0441\u044c \u0432 \u043d\u0435\u043a\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0438 \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445.\u00a0<\/p>\n<p>\u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u0434\u0432\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u043a\u0435\u0439\u0441\u0430\u0445 \u0432\u044b\u0448\u0435, \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0443 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 One step, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0437\u0430 \u043e\u0434\u0438\u043d \u0448\u0430\u0433.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"230\" width=\"230\">\n<p align=\"left\">\n<\/td>\n<td>\n<p><strong>Step by step<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>One step<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"230\" width=\"230\">\n<p align=\"left\"><strong>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>~280 ms<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>~161 ms<\/strong><\/p>\n<p align=\"left\"><strong>\u2013 57,5%<\/strong><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0421\u0442\u043e\u0438\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0437\u0430\u043c\u0435\u0440\u044b \u00ab\u0441\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435\u00bb, \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u043a\u0435\u0439\u0441\u044b, \u0433\u0434\u0435 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c step-by-step. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u0435\u0442 nginx \u0438\u043b\u0438 \u0411\u0414 \u043e\u0442\u0434\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u043f\u043e \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0443 \u0438\u043b\u0438 \u043f\u0430\u043c\u044f\u0442\u0438, \u043d\u043e, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0442\u0430\u043a\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u044b \u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c, \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f one step \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0438\u0433\u0440\u044b\u0448\u043d\u0430 \u0438\u0437-\u0437\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0445 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432.<\/p>\n<h2>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c: \u0420\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 (White list)<\/h2>\n<p>\u041f\u043b\u0430\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0442\u0435\u043c\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b\u043b\u0430 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430 \u0432\u043e \u0432\u0441\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0430, \u0430 \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043b\u0430\u043d \u0434\u043b\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u0438\u0437\u043d\u0435\u0441\u0430. GraphQL \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u043b\u0435\u0433\u0438\u0442\u0438\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0442\u0438\u043f\u0430\u043c\/\u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u0438 \u0438\u0445 \u043f\u043e\u043b\u044f\u043c \u043d\u0435 \u0440\u0435\u0433\u043b\u0430\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435.<\/p>\n<p>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0432 GraphQL \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0438\u0437\u043a\u043e\u0433\u043e\/\u0430\u0442\u043e\u043c\u0430\u0440\u043d\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u2013 \u043f\u043e\u043b\u0435\u0439. \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u0438 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u043e\u043b\u0435\u0439. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043d\u0435\u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0435\u0435 \u0443\u0442\u0435\u0447\u043a\u0435 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0443\u0433\u0440\u043e\u0437.<\/p>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0443\u0441\u0443\u0433\u0443\u0431\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0439\u0442\u0438 \u0435\u0434\u0438\u043d\u0443\u044e \u0432\u0445\u043e\u0434\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u0430 \u0431\u044b \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u0438\u0445 \u043f\u043e\u043b\u0435\u0439.<\/p>\n<p>\u041d\u0435 \u0431\u0443\u0434\u0443 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043f\u043e\u0438\u0441\u043a\u0430 \u0442\u0430\u043a\u043e\u0439 \u0442\u043e\u0447\u043a\u0438, \u0430 \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0439\u0434\u0443 \u043a \u043d\u0435\u0439.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043c\u044b \u0432\u044b\u043d\u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 query \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 $arConfig, \u0430 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 $config \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u043f\u043e\u043b\u0435\u0439. <\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430, \u0442.\u043a. \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043c\u044b \u043a \u043d\u0435\u0439 \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043f\u0440\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 (OR\/AND).<\/p>\n<pre><code class=\"php\">&lt;?php  class QueryType extends ObjectType {     public function __construct()     {         $arConfig = [ \/\/\u0412\u044b\u043d\u0435\u0441\u043b\u0438 \u043d\u0430\u0448\u0438 Query \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u043c\u0430\u0441\u0441\u0438\u0432             'news' => [                 'type' => Types::listOf(Types::news()),                 'args' => [                     'id' => Types::int(),                 ],                 'resolve' => function ($root, $args, $context, $info) {                     return News::get($args);                 }             ],             'rubric' => [],         ];         $config = [             'fields' => function () use ($arConfig) {                 \/\/\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u0432 \u043a \u043c\u0435\u0442\u043e\u0434\u0430\u043c \u0438 \u0435\u0433\u043e \u043f\u043e\u043b\u044f\u043c                 return Permission::processConfigFields($arConfig);             }         ];         parent::__construct($config);     } } <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0438\u0448\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430:<\/p>\n<pre><code class=\"php\">&lt;?php \/\/\u0444\u0430\u0439\u043b App\\Auth\\Permission.php  namespace GraphQL\\App\\Auth;  use GraphQL\\Server\\RequestError;  class Permission {     \/**      * \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u043c \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u043f\u043e\u043b\u0435\u0439 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f      *\/     private static $envConfig = [         [             \"LOGIN\" => \"TEST\",             \"PASSWORD\" => \"123456\",             \"WHITELIST\" => [                 \"news\" => [ \/\/ \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 news \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f                     \"id\",                     \"name\",                     \"text\"                 ]             ]         ],         [             \"LOGIN\" => \"RUBRIC_USER\",             \"PASSWORD\" => \"654321\",             \"WHITELIST\" => [                 \"rubric\" => []             ]         ]     ];      \/**      * @param $fields      * @return mixed      *\/     public static function processConfigFields($fields)     {         foreach ($fields as $code => $arField) {             $fields[$code]['resolve'] = function ($root, $args, $context, $info) use ($code, $arField) {                 $result = $arField['resolve']($root, $args, $context, $info);                 self::checkAccess($code, array_keys(current($result)));                 return $result;             };         }          return $fields;     }      \/**      * \u041c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0442\u0438\u043f\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0435\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c      *      * @param string $methodName      * @throws RequestError      *\/     private static function checkAccess(string $methodName, array $args)     {         if (!empty($_SERVER['PHP_AUTH_USER'])) {             foreach (self::$envConfig as $arUser) {                 if ($_SERVER['PHP_AUTH_USER'] == $arUser['LOGIN'] &amp;&amp; $_SERVER['PHP_AUTH_PW'] == $arUser['PASSWORD']) {  \/\/\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d \u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f                     if (!in_array($methodName, array_keys($arUser['WHITELIST']))) {                         throw new RequestError('Method ' . $methodName . ' is forbidden for user ' . $arUser['LOGIN'], 401);                     }                     foreach ($args as $field) { \/\/\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u044b \u043b\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f                         if ($arUser['WHITELIST'][$methodName] &amp;&amp; !in_array($field, $arUser['WHITELIST'][$methodName])) {                             throw new RequestError('Args ' . $field . ' is forbidden for user ' . $arUser['LOGIN'], 401);                         }                     }                 }             }         }     } } <\/code><\/pre>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<ul>\n<li>\n<p>\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e $envConfig \u2013 \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0442.\u0435.: <\/p>\n<ul>\n<li>\n<p>\u043b\u043e\u0433\u0438\u043d\/\u043f\u0430\u0440\u043e\u043b\u044c \u0434\u043b\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043c\u0435\u0442\u043e\u0434\u0430\u043c;<\/p>\n<\/li>\n<li>\n<p>\u0431\u0435\u043b\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u043f\u043e\u043b\u0435\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e.<\/p>\n<p>\u041a\u0430\u043a \u0438 \u043f\u0438\u0441\u0430\u043b \u0440\u0430\u043d\u0435\u0435, <strong><em>\u043a\u043e\u0434 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/em><\/strong>. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043d\/\u043f\u0430\u0440\u043e\u043b\u044c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0441\u0430\u0439\u0442\u0430 \u0438 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0432 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u0441\u0438\u0439. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u043d\u043e\u0441\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0441\u0430\u0439\u0442\u0430 SERVER[\u201cDOCUMENT_ROOT\u201d].<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434 processConfigFields \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0440\u0430\u0437\u0431\u043e\u0440 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0432 \u0431\u043e\u043b\u0435\u0435 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e checkAccess;<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434 checkAccess \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445: \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u043f\u043e\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u044b\u043b \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0443\u0434\u0430\u0447\u0438 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0438 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430. <\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c, \u0441\u0434\u0435\u043b\u0430\u0432 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u0438\u0437-\u043f\u043e\u0434 \u043d\u0435\u043b\u0435\u0433\u0438\u0442\u0438\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6dc\/7db\/874\/6dc7db874db217030ca18ea4624a870b.png\" width=\"904\" height=\"804\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6dc\/7db\/874\/6dc7db874db217030ca18ea4624a870b.png\"\/><\/figure>\n<h2>\u0413\u0438\u0431\u043a\u043e\u0441\u0442\u044c: \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u0441 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 OR\/AND<\/h2>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e:<\/p>\n<ul>\n<li>\n<p>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0432 Query-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430\u043b\u0435\u0442\u0443;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432 \u0442\u0438\u043f Query \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043b\u0430\u0441\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\/\u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u0432\u0441\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u0441 \u0442\u0438\u043f\u0430\u043c\u0438 \u201cOR\u201d\/\u201dAND\u201d \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0430\u043b\u0442\u0430\u0439\u043c\u0430, <strong>\u041d\u041e:<\/strong><\/p>\n<p><strong>\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043e\u0434\u043d\u043e\u0438\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u044b\u0434\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443.<\/strong><\/p>\n<p><em>\u00abSchema\u00a0must\u00a0contain\u00a0unique\u00a0named\u00a0types\u00a0but\u00a0contains\u00a0multiple\u00a0types\u00a0named\u00a0&#171;\\GraphQL\\App\\Type\\Input\\MixedInputType&#187;\u00a0(see\u00a0<\/em><a href=\"http:\/\/webonyx.github.io\/graphql-php\/type-system\/#type-registry\"><em>http:\/\/webonyx.github.io\/graphql-php\/type-system\/#type-registry<\/em><\/a><em>).\u00bb<\/em><\/p>\n<p>\u0414\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u00ab\u0441\u043e\u043b\u044c\u00bb \u043f\u0440\u0438 \u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u00a0\u041e\u043d\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438: news, rubric \u0438 \u0442.\u0434.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u00ab\u0441\u043e\u043b\u0438\u00bb \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c hash \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0435\u0433\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0442\u0438\u043f, \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u044f \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0430. \u0412 \u0438\u0442\u043e\u0433\u0435, \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043d\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: MixedInputType05afd6ecb065cfd7b660a6b6a59a54cf.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"php\">&lt;?php class MixedInputType extends InputObjectType {     public function __construct(array $arExtendedFields = [])     {         $sHashGenerated = md5(implode(',', $arExtendedFields));\/\/\u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0445\u0435\u0448 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432         $config = [             'name' => self::class . $sHashGenerated,\/\/\u0430\u0432\u0442\u043e\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0445\u0435\u043c\u044b \u0442\u0438\u043f\u043e\u0432, \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, GraphQL\\App\\Type\\Input\\MixedInputType05afd6ecb065cfd7b660a6b6a59a54cf             'fields' => function () use ($arExtendedFields, $sHashGenerated) {                 return [\/\/\u0430\u0432\u0442\u043e\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 \u0434\u043b\u044f Query \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432                     'OR' => [                         'type' => Types::listOf(                             new InputObjectType(                                 [                                     'name' => self::class . 'OR' . $sHashGenerated,                                     'fields' => function () use ($arExtendedFields) {                                         return $arExtendedFields;                                     }                                 ]                             )                         )                     ],                     'AND' => [                         'type' => Types::listOf(                             new InputObjectType(                                 [                                     'name' => self::class . 'AND' . $sHashGenerated,                                     'fields' => function () use ($arExtendedFields) {                                         return $arExtendedFields;                                     }                                 ]                             )                         )                     ]                 ];             }         ];         parent::__construct($config);     } } <\/code><\/pre>\n<p>\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u0442\u0438\u043f \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u044d\u0442\u043e \u0438\u043c\u044f \u0442\u0438\u043f\u0430 \u2013 \u043e\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c:<\/p>\n<pre><code class=\"php\">&lt;?php class Types extends Type {     private static $query;     private static $mixedInput;      public static function query()     {         return self::$query ?: (self::$query = new QueryType());     }      \/**\u0421\u043c\u0435\u0448\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f query \u0437\u0430\u043f\u0440\u043e\u0441\u0430*\/     public static function mixedInput(array $arExtendedFields = [])     {         $sArguments = md5(implode(',', $arExtendedFields));         return self::$mixedInput[$sArguments] ?: self::$mixedInput[$sArguments] = new MixedInputType($arExtendedFields);     } } <\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u0432, \u0432\u043d\u0435\u0434\u0440\u0438\u043c \u0432 \u0435\u0434\u0438\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"php\">&lt;?php class QueryType extends ObjectType {     public function __construct()     {         $arConfig = [\/\/\u0412\u044b\u043d\u0435\u0441\u043b\u0438 \u043d\u0430\u0448\u0438 Query \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u043c\u0430\u0441\u0441\u0438\u0432             'news' => [                 'type' => Types::listOf(Types::news()),                 'args' => ['id' => Types::int()],                 'resolve' => function ($root, $args, $context, $info) {return News::get($args);}             ],         ];         $config = [\/\/\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445             'fields' => function () use ($arConfig) {                 foreach ($arConfig as $sCodeConfig => $arParams) {                     $arConfig[$sCodeConfig]['args']['filter'] = Types::listOf(Types::mixedInput($arConfig[$sCodeConfig]['args']));                 }                 return $arConfig;             }         ];         parent::__construct($config);     } }<\/code><\/pre>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0440\u0438\u0441\u0443\u043d\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0440\u0443\u0447\u043d\u044b\u043c \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439. \u0421\u0442\u043e\u0438\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0435 \u043d\u0438\u0436\u0435 (\u0440\u0443\u0447\u043d\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f) \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u043a\u0443\u0441\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e query \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u043a\u0438 \u00abOR\u00bb, \u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0442\u0438 \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044e \u043d\u043e\u0432\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u041f\u0440\u0438 \u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u043d. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6c9\/a43\/f4a\/6c9a43f4a12135369fba12989dba8852.png\" width=\"904\" height=\"462\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6c9\/a43\/f4a\/6c9a43f4a12135369fba12989dba8852.png\"\/><\/figure>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u0441\u043b\u0430\u0432 query \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0432 \u0444\u0438\u043b\u044c\u0442\u0440\u0435 \u043b\u043e\u0433\u0438\u043a\u0438 \u00abOR\u00bb:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/109\/2d6\/ea3\/1092d6ea3d5a49693a83652622197abb.png\" width=\"904\" height=\"688\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/109\/2d6\/ea3\/1092d6ea3d5a49693a83652622197abb.png\"\/><\/figure>\n<p>\u041f\u043e \u0438\u0442\u043e\u0433\u0430\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0434\u0432\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u0441 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u044b\u043c\u0438 ID.<\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>\u041c\u044b \u043e\u043f\u0438\u0441\u0430\u043b\u0438 >20 \u00ab\u043f\u0440\u043e\u0441\u0442\u044b\u0445\u00bb \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043e\u0434\u0438\u043d \u00ab\u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0439\u00bb \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0442\u0440\u0435\u0445 \u043f\u043e\u0434\u0442\u0438\u043f\u043e\u0432.<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u043d\u0438\u0436\u0435, \u043d\u0430\u043c \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c >1 000 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0439\/\u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0439.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/583\/025\/28d\/58302528d6fe654886416f714023ace7.png\" width=\"480\" height=\"152\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/583\/025\/28d\/58302528d6fe654886416f714023ace7.png\"\/><\/figure>\n<p>\u041a\u0440\u0430\u0442\u043a\u0438\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438:<\/p>\n<ul>\n<li>\n<p><strong>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f One step-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/strong>;<\/p>\n<\/li>\n<li>\n<p><strong>\u0417\u0430\u043b\u043e\u0436\u0438\u0442\u0435<\/strong> <strong>\u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 <\/strong>\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u0438 \u0438\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f;<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <\/strong>\u0441 \u0447\u0435\u0442\u043a\u043e\u0439 \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0435\u0439 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e;<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0444\u0438\u043b\u044c\u0442\u0440 <\/strong>\u0441\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><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:\/\/habr.com\/ru\/articles\/780328\/\"> https:\/\/habr.com\/ru\/articles\/780328\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u041d\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0435, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0435\u0447\u0435\u0433\u043e \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0434\u043e\u043c\u0430 \u043e\u0434\u043d\u0430 \u043a\u0430\u0440\u0442\u043e\u0448\u043a\u0430. \u041f\u0440\u0438 \u0441\u043c\u0435\u043a\u0430\u043b\u043a\u0435 \u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043f\u0435\u0446\u0438\u0439 \u2014 \u043f\u044e\u0440\u0435, \u0434\u0440\u0430\u043d\u0438\u043a\u0438, \u0437\u0430\u043f\u0435\u043a\u0430\u043d\u043a\u0430, \u0447\u0438\u043f\u0441\u044b \u0444\u0440\u0438&#8230; \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u044b \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u0435\u043c \u043d\u0435 \u043a\u0443\u043b\u0438\u043d\u0430\u0440\u0438\u044e. \u041c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e GraphQL \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0444\u0438\u0447\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0432\u043d\u0435\u0434\u0440\u0438\u043b\u0438 \u0443 \u0441\u0435\u0431\u044f \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438, \u0438 \u0442\u0438\u0440\u0430\u0436\u0438\u0440\u0443\u0435\u043c \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b, \u0433\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u044d\u0442\u043e\u0442 \u044f\u0437\u044b\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0438 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438 GraphQL \u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440\u0430\u043c, \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0442\u043e\u0440\u0430\u043c, \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u043c \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u00ab\u043a\u043e\u0434\u0430\u00bb, \u0430 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442 \u043f\u043e\u043b\u043d\u044b\u0439 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443, \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435, \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u0438 \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435. <\/p>\n<figure class=\"full-width\"><\/figure>\n<h2>GraphQL: \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0438 \u0441\u043e\u0432\u0435\u0442\u044b<\/h2>\n<p>GraphQL \u2014 \u044d\u0442\u043e \u044f\u0437\u044b\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c.<\/p>\n<p>\u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u044f\u0437\u044b\u043a\u0430:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0442\u043e\u0447\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0435\u043c\u0443 \u043d\u0443\u0436\u043d\u044b;<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0442\u0438\u043f\u043e\u0432 \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0432\u044b\u0448\u0435 \u0443\u043a\u0430\u0437\u0430\u043d \u0433\u0440\u0430\u0444, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u0442\u0438\u043f\u043e\u0432: users, rubrics, news, comment. \u041d\u043e \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0435\u0439, \u0431\u043e\u043b\u0435\u0435 10-\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043e\u043f\u0438\u0441\u0430\u0432 \u0447\u0435\u0442\u044b\u0440\u0435 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0432\u0430\u0440\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u044b \u043c\u044b \u0441\u0442\u0430\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/webonyx\/graphql-php\">\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u043f\u043b\u043e\u0445\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u043e\u0441\u0442\u0440\u044f\u0442\u044c \u043d\u0430 \u044d\u0442\u043e\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c.<\/p>\n<p>\u0417\u0430 \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0441\u0432\u043e\u0438 must have \u043f\u0440\u0430\u0432\u0438\u043b\u0430\/\u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0442\u0438\u0440\u0430\u0436\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043d\u0438\u0445.<\/p>\n<p><strong><em>\u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043a\u043e\u0434,<\/em><\/strong> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043d\u0438\u0436\u0435:<\/p>\n<ul>\n<li>\n<p>\u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c PHP \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u043e\u0431\u0440\u0430\u0442\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u0445\u043e\u0434\u043d\u044b\u0445\/\u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0442.\u0434.;<\/p>\n<\/li>\n<li>\n<p><strong><em>\u043d\u043e\u0441\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440 \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f\/\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430;<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p>\u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0432 \u0447\u0438\u0441\u0442\u043e\u043c \u0432\u0438\u0434\u0435.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/h2>\n<p>\u0412 GraphQL \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u0445 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<p><strong>MutationType<\/strong> \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p><strong>QueryType<\/strong> \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p><strong>SubscriptionType <\/strong>\u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u043d\u043e \u043e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u00ab\u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445\u00bb \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a PHP \u0438\u043b\u0438 PHP > 8.1 (\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f <a href=\"https:\/\/github.com\/webonyx\/graphql-php\">\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/a>). \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \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. \u0423 \u0441\u0435\u0431\u044f \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u043e\u043a, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0448\u0438\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0431\u0440\u043e\u043a\u0435\u0440\u044b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438 \u0442.\u0434.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043d\u0438\u0436\u0435:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b \/graphql\/index.php \u0441 \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c:<\/p>\n<pre><code class=\"php\">&lt;?php \/\/\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c GraphQL require_once realpath('..\/vendor\/autoload.php');  try {     \/\/\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435     $rawInput = file_get_contents('php:\/\/input');     $input = json_decode($rawInput, true);     $query = $input['query'];          \/\/\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0445\u0435\u043c\u0443     $schema = new Schema([         'query' => Types::query(),         'mutation' => Types::mutation()     ]);          \/\/\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441     $result = GraphQL::executeQuery($schema, $query);     $arException = $result->toArray()['errors'] ?: [];  \/\/\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0438 } catch (Throwable $e) {     $result = ['error' => ['message' => $e->getMessage()]]; } finally {     \/\/\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435     Log::push($query, $arException); }  \/\/\u0412\u044b\u0432\u043e\u0434\u0438\u043c \u043e\u0442\u0432\u0435\u0442 header('Content-Type: application\/json; charset=UTF-8'); echo json_encode($result);<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0442\u0438\u043f\u0430, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e:<\/p>\n<ul>\n<li>\n<p>\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e;<\/p>\n<\/li>\n<li>\n<p>\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 \u0442\u0438\u043f, \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043d\u0430 \u043d\u043e\u0432\u043e\u0441\u0442\u0438 (news) \u0438 \u0440\u0443\u0431\u0440\u0438\u043a\u0438 (rubrics). \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p><strong>\u041e\u043f\u0438\u0448\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 news:<\/strong><\/p>\n<pre><code class=\"php\">&lt;?php class QueryType extends ObjectType {     public function __construct()     {         $config = [             'fields' => function () {                 return [                     'news' => [ \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c query \u0437\u0430\u043f\u0440\u043e\u0441 news                         'type' => Types::news(), \/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445                         'args' => [                             'id' => Types::int(), \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u0432\u043e\u0441\u0442\u044c                         ],                         'resolve' => function ($root, $args, $context, $info) {                             return News::get($args); \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 get \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430                         }                     ]                 ];             }         ];         parent::__construct($config);     } }<\/code><\/pre>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 &#171;QueryType&#187; \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0432\u0441\u0435 \u043f\u043e\u0434\u0442\u0438\u043f\u044b &#171;query&#187; \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0438 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d \u043e\u0442 &#171;ObjectType&#187;, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u00a0\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0442\u0438\u043f news:<\/p>\n<pre><code class=\"php\">&lt;?php class Types extends Type {     private static $query;     private static $news;     private static $rubric;      public static function query()     {         return self::$query ?: (self::$query = new QueryType());     }      public static function news() \/\/ \u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f     {         return self::$news ?: (self::$news = new NewsType()); \/\/\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430     } } <\/code><\/pre>\n<p>\u041e\u043f\u0438\u0448\u0435\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u0442\u0438\u043f\u0430 news:<\/p>\n<pre><code class=\"php\">&lt;?php class NewsType extends ObjectType {     public function __construct()     {         $config = [             'fields' => function () {                 return [ \/\/\u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u043f\u043e\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0438\u0445 \u0442\u0438\u043f\u044b                     'id' => [                         'type' => Types::int(),\/\/id \u043d\u043e\u0432\u043e\u0441\u0442\u0438                     ],                     'name' => [                         'type' => Types::string(),\/\/\u0438\u043c\u044f \u043d\u043e\u0432\u043e\u0441\u0442\u0438                     ],                     'text' => [                         'type' => Types::string(),\/\/\u0442\u0435\u043a\u0441\u0442 \u043d\u043e\u0432\u043e\u0441\u0442\u0438                     ],                 ];             }         ];         parent::__construct($config);     } } <\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c:<\/p>\n<pre><code class=\"php\">&lt;?php namespace GraphQL\\App\\Type;  use GraphQL\\App\\DB\\ConnectDB;  class News {     public static function get($args)     {         $DB = new ConnectDB();         return $DB->query(\"SELECT * from news WHERE id = {$args['id']}\")[0];     } }<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0434\u0435\u043b\u0430\u0432 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u0448\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u0441\u043b\u0430\u0432 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0443\u043a\u0430\u0437\u0430\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0430\u0431\u043e\u0440 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a GraphQL \u2013 \u044d\u0442\u043e \u0443\u043c\u043d\u044b\u0439 endpoint, \u0442\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u043f\u043e\u043b\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e id \u0438 name \u043d\u043e\u0432\u043e\u0441\u0442\u0438. \u0421\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0436\u0443, \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!) \u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u043d\u0438\u0436\u0435.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0443\u0431\u0435\u0434\u0438\u043b\u0438\u0441\u044c, \u0447\u0442\u043e GraphQL \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u00ab\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044e\u00bb.<\/p>\n<p><strong>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c: \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 (One step)<\/strong><\/p>\n<p>\u041a\u0430\u043a \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u0440\u0430\u043d\u0435\u0435, \u043d\u043e\u0432\u043e\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438, \u0432 \u0442\u043e\u043c \u0438 \u0447\u0438\u0441\u043b\u0435 \u0438 \u0441 \u0440\u0443\u0431\u0440\u0438\u043a\u043e\u0439.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u043f\u0438\u0448\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0442\u0438\u043f\u0430 rubric, \u043e\u043d \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0442\u0438\u043f\u0430 news:<\/p>\n<pre><code class=\"php\">&lt;?php class QueryType extends ObjectType {     public function __construct()     {         $config = [             'fields' => function () {                 return [                     'news' => [\/*...*\/],                     'rubric' => [ \/\/\u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441                         'type' => Types::rubric(), \/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 - \u0440\u0443\u0431\u0440\u0438\u043a\u0430                         'args' => [                             'id' => Types::int(), \/\/ \u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0443\u0431\u0440\u0438\u043a\u0443                         ],                         'resolve' => function ($root, $args, $context, $info) {                             return Rubric::get($args); \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 get \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430                         }                     ]                 ];             }         ];         parent::__construct($config);     } } <\/code><\/pre>\n<p>\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e:<\/p>\n<pre><code class=\"php\">&lt;?php class Types extends Type {     private static $query;     private static $news;     private static $rubric;      public static function query()     {         return self::$query ?: (self::$query = new QueryType());     }      public static function news()     {         return self::$news ?: (self::$news = new NewsType());     }      public static function rubric() \/\/ \u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f     {         return self::$rubric ?: (self::$rubric = new RubricType()); \/\/ \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430     } } <\/code><\/pre>\n<p>\u041e\u043f\u0438\u0448\u0435\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f:<\/p>\n<pre><code class=\"php\">&lt;?php class RubricType extends ObjectType {     public function __construct()     {         $config = [             'fields' => function () {                 return [ \/\/\u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u043f\u043e\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0438\u0445 \u0442\u0438\u043f\u044b                     'id' => [\/\/id \u0440\u0443\u0431\u0440\u0438\u043a\u0438                         'type' => Types::int(),                     ],                     'name' => [\/\/\u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0443\u0431\u0440\u0438\u043a\u0438                         'type' => Types::string(),                     ],                     'code' => [\/\/\u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0440\u0443\u0431\u0440\u0438\u043a\u0438                         'type' => Types::string(),                     ],                 ];             }         ];         parent::__construct($config);     } } <\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c:<\/p>\n<pre><code class=\"php\">&lt;?php  namespace GraphQL\\App\\Type;  use GraphQL\\App\\DB\\ConnectDB;  class Rubric {     public static function get($args)     {         $DB = new ConnectDB();         return $DB->query(\"SELECT * from rubrics WHERE id = {$args['id']}\")[0];     } }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043c \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u043e\u0441\u0442\u044c \u0441 \u0440\u0443\u0431\u0440\u0438\u043a\u043e\u0439, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0440\u0443\u0431\u0440\u0438\u043a\u0438:<\/p>\n<pre><code class=\"php\">&lt;?php  class NewsType extends ObjectType {     public function __construct()     {         $config = [             'fields' => function () {                 return [                     'id' => [                         'type' => Types::int(),                     ],                     'name' => [                         'type' => Types::string(),                     ],                     'text' => [                         'type' => Types::string(),                     ],                     'rubric' => [                         'type' => Types::Rubric(), \/\/\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0438\u043f \u0434\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 id \u0440\u0443\u0431\u0440\u0438\u043a                     ],                 ];             } <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-362817","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/362817","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=362817"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/362817\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=362817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=362817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=362817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}