{"id":299458,"date":"2020-02-28T21:00:24","date_gmt":"2020-02-28T21:00:24","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=299458"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=299458","title":{"rendered":"\u0414\u0435\u043b\u0430\u0435\u043c \u043a\u043b\u043e\u043d \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043f\u043e \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0435 \u0435\u0434\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Nuxt.js, GraphQL, Strapi \u0438 Stripe. \u0427\u0430\u0441\u0442\u044c 2\/7"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/490332\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/vk\/wy\/ir\/vkwyirklvvrzoochiqmwlxbc6-g.jpeg\" alt=\"image\"><\/p>\n<p>  <\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/489676\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c Strapi API \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0432\u0441\u0435\u0439 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d <a href=\"https:\/\/github.com\/strapi\/strapi-tutorials\/tree\/master\/tutorials\/deliveroo-clone-nuxt-strapi-tutorial\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/em><\/p>\n<p>  <\/p>\n<h3 id=\"sozdaem-restorany\">\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u044b<\/h3>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0434\u0430\u043d\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0447\u0435\u0440\u0435\u0437 Strapi API, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c.<\/p>\n<p>  <\/p>\n<h3 id=\"ustanavlivaem-content-type\">\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c Content Type<\/h3>\n<p>  <\/p>\n<p>Content Type, \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c\u044e (<code>model<\/code>). Strapi API \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043c\u043e\u0434\u0435\u043b\u044c <code>user<\/code>. \u0421\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043a\u0430\u043a \u0432\u044b \u0443\u0436\u0435 \u0434\u043e\u0433\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f <code>restaurant<\/code>(\u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u043c\u0435\u043d\u0443\u044e\u0442\u0441\u044f \u0432 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u0447\u0438\u0441\u043b\u0435).<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043c\u043e\u0434\u0435\u043b\u0435\u0439\u00a0<a href=\"http:\/\/localhost:1337\/admin\/plugins\/content-type-builder\">http:\/\/localhost:1337\/admin\/plugins\/content-type-builder<\/a><\/li>\n<li>\u041d\u0430\u0436\u0430\u0442\u044c \u043d\u0430 <code>Create new content-type<\/code><\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u00a0<code>restaurant<\/code>\u00a0\u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043c\u0435\u043d\u0438 \u0438 \u043d\u0430\u0436\u0430\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0443 &quot;Continue&quot;<\/li>\n<li>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u043b\u044f:<br \/> \n<ul>\n<li><code>name<\/code>\u00a0\u0441 \u0442\u0438\u043f\u043e\u043c\u00a0<strong>Text<\/strong><\/li>\n<li><code>description<\/code>\u00a0\u0441 \u0442\u0438\u043f\u043e\u043c\u00a0<strong>Rich Text<\/strong><\/li>\n<li><code>image<\/code>\u00a0\u0441 \u0442\u0438\u043f\u043e\u043c <strong>Media<\/strong><\/li>\n<\/ul>\n<\/li>\n<li>\u041d\u0430\u0436\u0430\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0438 &quot;Finish&quot; \u0438 \u043f\u043e\u0441\u043b\u0435 &quot;Save&quot;<\/li>\n<\/ul>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/22f\/96d\/8f2\/22f96d8f2eee2daecf11a9bf64e55d3d.gif\" alt=\"image\"><\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0441\u044f \u0438 \u043d\u043e\u0432\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430 <code>Restaurant<\/code> \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432 \u043b\u0435\u0432\u043e\u043c \u043c\u0435\u043d\u044e.<\/p>\n<p>  <\/p>\n<h3 id=\"dobavlyaem-zapisi\">\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0438<\/h3>\n<p>  <\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u0435\u0440\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432 \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"http:\/\/localhost:1337\/admin\/plugins\/content-manager\/application::restaurant.restaurant\">Restaurant<\/a> \u0432 \u043b\u0435\u0432\u043e\u043c \u043c\u0435\u043d\u044e.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u0432 \u043f\u043b\u0430\u0433\u0438\u043d\u0435 <code>Content Manager<\/code>, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c, \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041d\u0430\u0436\u043c\u0438\u0442\u0435\u00a0\u043d\u0430 <code>Add New Restaurant<\/code><\/li>\n<li>\u0423\u043a\u0430\u0436\u0438\u0442\u0435\u00a0<code>name<\/code>, \u00a0<code>description<\/code>\u00a0\u0438 \u043f\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0432 \u043f\u043e\u043b\u0435\u00a0<code>image<\/code><\/li>\n<li>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0435\u0449\u0435 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0cf\/745\/d98\/0cf745d98467537a073f45d8b0374546.gif\" alt=\"image\"><\/p>\n<p>  <\/p>\n<h3 id=\"razreshaem-dostup\">\u0420\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f<\/h3>\n<p>  <\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0431\u0430\u0437\u0435 \u0438\u0437 API \u0435\u0449\u0435 \u043b\u0443\u0447\u0448\u0435. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c <code>restaurant<\/code>, \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c Strapi \u0441\u043e\u0437\u0434\u0430\u043b \u0440\u044f\u0434 \u0444\u0430\u0439\u043b\u043e\u0432 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0432 <code>api\/restaurant<\/code>. \u042d\u0442\u0438 \u0444\u0430\u0439\u043b\u044b \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u0432 \u0441\u0435\u0431\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u043e\u0435 CRUD API. \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432 <code>find<\/code> \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0437\u0434\u0435\u0441\u044c: <a href=\"http:\/\/localhost:1337\/restaurants\">http:\/\/localhost:1337\/restaurants<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043f\u044b\u0442\u0430\u0432\u0448\u0438\u0441\u044c \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 URL, \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0443\u0434\u0438\u0432\u043b\u0435\u043d\u044b \u0443\u0432\u0438\u0434\u0435\u0432 403 \u043e\u0448\u0438\u0431\u043a\u0443. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e: \u043d\u043e\u0432\u044b\u0435 Strapi API \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0442\u0430\u043a\u0438\u043c\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<p>  <\/p>\n<p>\u041d\u0435 \u0432\u043e\u043b\u043d\u0443\u0439\u0442\u0435\u0441\u044c, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u043e\u0443\u0442 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u00a0\u043d\u0430 \u0432\u043a\u043b\u0430\u0434\u043a\u0443 <code>Roles &amp; Permissions<\/code>\u00a0<a href=\"http:\/\/localhost:1337\/admin\/plugins\/users-permissions\">http:\/\/localhost:1337\/admin\/plugins\/users-permissions<\/a>.<\/li>\n<li>\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435\u00a0<code>Public<\/code><\/li>\n<li>\u041f\u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0433\u0430\u043b\u043e\u0447\u043a\u0443 \u0432 \u0447\u0435\u043a\u0431\u043e\u043a\u0441\u0430\u0445\u00a0<code>find<\/code>\u00a0\u0438\u00a0<code>findone<\/code>\u00a0 \u0441\u0435\u043a\u0446\u0438\u0438\u00a0<code>Restaurant<\/code><\/li>\n<li>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u0412\u0430\u0436\u043d\u043e:<\/strong> \u0441\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u043b\u044f \u0440\u043e\u043b\u0438 <code>authenticated<\/code><\/p>\n<p>  <\/p>\n<ul>\n<li>\u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u00a0\u043d\u0430 \u0432\u043a\u043b\u0430\u0434\u043a\u0443<code>Roles &amp; Permissions<\/code>\u00a0\u00a0<a href=\"http:\/\/localhost:1337\/admin\/plugins\/users-permissions\">http:\/\/localhost:1337\/admin\/plugins\/users-permissions<\/a>.<\/li>\n<li>\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <code>Authenticated<\/code><\/li>\n<li>\u041f\u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0433\u0430\u043b\u043e\u0447\u043a\u0443 \u0432 \u0447\u0435\u043a\u0431\u043e\u043a\u0441\u0430\u0445\u00a0<code>find<\/code>\u00a0\u0438\u00a0<code>findone<\/code>\u00a0 \u0441\u0435\u043a\u0446\u0438\u0438\u00a0<code>Restaurant<\/code><\/li>\n<li>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043d\u0430\u0437\u0430\u0434 \u043d\u0430\u00a0<a href=\"http:\/\/localhost:1337\/restaurants\">http:\/\/localhost:1337\/restaurants<\/a>, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/dd6\/0aa\/e33\/dd60aae331e1076d2ceb78a534a580ce.gif\" alt=\"image\"><\/p>\n<p>  <\/p>\n<h3 id=\"vklyuchaem-graphql\">\u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c GraphQL<\/h3>\n<p>  <\/p>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e API \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 REST \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u0427\u0442\u043e \u0435\u0441\u043b\u0438 \u044f \u0441\u043a\u0430\u0436\u0443 \u0432\u0430\u043c, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0435\u0433\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432 GraphQL \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0438 10 \u0441\u0435\u043a\u0443\u043d\u0434?<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u0430\u043a.<\/p>\n<p>  <\/p>\n<p>\u041f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f GraphQL \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 Strapi, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>\/backend<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">yarn strapi install graphql # \u0438\u043b\u0438 npm run strapi install graphql<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435, \u0441 \u0431\u0435\u043a\u0435\u043d\u0434\u043e\u043c \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e45\/2d2\/438\/e452d2438c9c71c30d7d4ba2e4733ce8.png\" alt=\"https:\/\/blog.strapi.io\/content\/images\/2018\/07\/Screen-Shot-2018-07-02-at-17.03.38.png\"><\/p>\n<p>  <\/p>\n<ul>\n<li>\u041f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0441\u0435\u0440\u0432\u0435\u0440 (<code>yarn develop<\/code>\u00a0\u0438\u043b\u0438\u00a0<code>npm run develop<\/code>)<\/li>\n<li>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043d\u0430\u00a0<a href=\"http:\/\/localhost:1337\/graphql\">http:\/\/localhost:1337\/graphql<\/a>\u00a0\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"plaintext\">{       restaurants {         id # \u0418\u043b\u0438 _id \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 MongoDB         name       } }<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/56e\/864\/320\/56e864320208cf0a47d572edeebed943.gif\" alt=\"https:\/\/blog.strapi.io\/content\/images\/2019\/09\/graphql-1.gif\"><\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0448\u0430\u0433\u0443:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c GraphQL \u0438 @nuxt-apollo \u0432 \u043d\u0430\u0448\u0443 <code>\/frontend<\/code> \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"plaintext\">yarn add @nuxtjs\/apollo graphql # \u0438\u043b\u0438 npm install @nuxtjs\/apollo graphql<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u043e\u0434\u0443\u043b\u0438 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f apollo \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0432 <code>nuxt.config.js<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">    ...     modules: [ '@nuxtjs\/apollo',     ],     apollo: { clientConfigs: { default: { httpEndpoint: 'http:\/\/localhost:1337\/graphql' } }     },     ...<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"pokazyvaem-restorany\">\u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u044b<\/h3>\n<p>  <\/p>\n<p>\u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u043c\u044b \u0434\u0432\u0438\u0436\u0435\u043c\u0441\u044f \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u044b \u0432 Nuxt \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u044b \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c <code>.\/pages\/restaurants\/index.vue<\/code> \u0444\u0430\u0439\u043b \u0438 \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"xml\">&lt;template&gt;         &lt;div&gt;           \/\/ \u041f\u043e\u0438\u0441\u043a \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432           &lt;form class=&quot;uk-search uk-search-large uk-align-center uk-margin&quot;&gt;               &lt;span uk-search-icon&gt;&lt;\/span&gt;               &lt;input class=&quot;uk-search-input&quot; v-model=&quot;query&quot; type=&quot;search&quot; placeholder=&quot;Search...&quot;&gt;           &lt;\/form&gt;            \/\/ \u041a\u0430\u0440\u0442\u043e\u0447\u043a\u0438 \u0441 \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0430\u043c\u0438           &lt;div class=&quot;uk-card uk-card-default uk-grid-collapse uk-child-width-1-2@m uk-margin&quot; v-for=&quot;restaurant in filteredList&quot; v-bind:key=&quot;restaurant&quot; uk-grid&gt;               &lt;div class=&quot;uk-card-media-left uk-cover-container&quot;&gt;                   &lt;img :src=&quot;'http:\/\/localhost:1337\/' + restaurant.image.url&quot; alt=&quot;&quot; uk-cover&gt;                   &lt;canvas width=&quot;600&quot; height=&quot;400&quot;&gt;&lt;\/canvas&gt;               &lt;\/div&gt;               &lt;div&gt;                   &lt;div class=&quot;uk-card-body&quot;&gt;                       &lt;h3 class=&quot;uk-card-title&quot;&gt;{{ restaurant.name }}&lt;\/h3&gt;                       &lt;p&gt;{{ restaurant.description }}&lt;\/p&gt;                       \/\/ \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u044b                       &lt;router-link :to=&quot;{ name: 'restaurants-id', params: { id: restaurant.id }}&quot; tag=&quot;a&quot; class=&quot;uk-button uk-button-primary&quot;&gt;See dishes                       &lt;\/router-link&gt;                   &lt;\/div&gt;               &lt;\/div&gt;           &lt;\/div&gt;            \/\/ \u0415\u0441\u043b\u0438 \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e           &lt;div class=&quot;uk-container uk-container-center uk-text-center&quot; v-if=&quot;filteredList.length == 0&quot;&gt;            &lt;img src=&quot;https:\/\/assets-ouch.icons8.com\/preview\/19\/52de2377-696e-4194-8c63-0a81aef60b4f.png&quot; height=&quot;800&quot; width=&quot;800&quot;&gt;            &lt;p&gt;No restaurants found&lt;\/p&gt;          &lt;\/div&gt;        &lt;\/div&gt;  &lt;\/template&gt;  &lt;script&gt;       \/\/ \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432     import restaurantsQuery from '~\/apollo\/queries\/restaurant\/restaurants'      export default {         data() {         return {           \/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0443\u0441\u0442\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441 \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0430\u043c\u0438           restaurants: [],           query: ''         }       },       apollo: {         restaurants: {           prefetch: true,           query: restaurantsQuery         }       },       computed: {         \/\/ \u0418\u0449\u0435\u043c \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u044b         filteredList() {           return this.restaurants.filter(restaurant =&gt; {             return restaurant.name.toLowerCase().includes(this.query.toLowerCase())           })         },       }     } &lt;\/script&gt;<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"chto-my-napisali\">\u0427\u0442\u043e \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438?<\/h3>\n<p>  <\/p>\n<p>\u0414\u0432\u0435 \u0433\u043b\u0430\u0432\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u2014 \u0448\u0430\u0431\u043b\u043e\u043d \u0438 \u0441\u043a\u0440\u0438\u043f\u0442. \u042d\u0442\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u0442\u0438\u043f\u0438\u0447\u043d\u044b \u0434\u043b\u044f Vue.js \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0434\u0435\u043b \u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u043a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b \u0434\u043b\u044f Vue.js:<\/p>\n<p>  <\/p>\n<ol>\n<li><code>v-for<\/code>: \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442 \u0442\u0435\u0433 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437 \u0440\u0430\u0432\u043d\u043e\u0435 \u0434\u043b\u0438\u043d\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 (<code>restaurants<\/code> \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435).<\/li>\n<li><code>v-if<\/code>: \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0442\u0435\u0433 \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0432\u0430\u043b\u0438\u0434\u043d\u043e.<\/li>\n<li><code>v-model<\/code>: \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0438\u043d\u043f\u0443\u0442\u0430. \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043b\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432 \u043f\u043e \u0438\u0445 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e.<\/li>\n<li><code>vue-router<\/code>: \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443.<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u0412 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0438 \u043c\u043e\u0434\u0443\u043b\u0438.<\/p>\n<p>  <\/p>\n<h3 id=\"graphql-zapros\">GraphQL \u0437\u0430\u043f\u0440\u043e\u0441<\/h3>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>restaurantsQuery<\/code> GraphQL \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e apollo \u0437\u0434\u0435\u0441\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">... apollo: { restaurants: { prefetch: true, query: restaurantsQuery } }, ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a Strapi API.<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0421\u043e\u0437\u0434\u0430\u0435\u043c <code>\/frontend\/apollo\/queries\/restaurant\/restaurants.gql<\/code> \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"plaintext\">    query Restaurants {         restaurants {         id         name         description         image {           url         }       }     }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432!<\/strong><\/p>\n<p>  <\/p>\n<hr>\n<p>  <\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u043a\u0430\u043a \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0431\u043b\u044e\u0434.<\/p>\n<\/div>\n<p> \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\/post\/490332\/\"> https:\/\/habr.com\/ru\/post\/490332\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/490332\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/vk\/wy\/ir\/vkwyirklvvrzoochiqmwlxbc6-g.jpeg\" alt=\"image\"><\/p>\n<p>  <\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/489676\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c Strapi API \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u043e\u0432.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-299458","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299458","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=299458"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299458\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}