{"id":470736,"date":"2025-08-14T15:00:27","date_gmt":"2025-08-14T15:00:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=470736"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=470736","title":{"rendered":"<span>\u0413\u0430\u0439\u0434 \u043f\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e Spring GraphQL. \u0427\u0430\u0441\u0442\u044c 2<\/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>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0414\u043c\u0438\u0442\u0440\u0438\u0439, \u044f \u0431\u044d\u043a\u0435\u043d\u0434-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 <a href=\"https:\/\/t.me\/it_sense\" rel=\"noopener noreferrer nofollow\">SENSE<\/a> \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 10 \u043b\u0435\u0442 \u043f\u0438\u0448\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043d\u0430 Java. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u2013 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 <a href=\"https:\/\/habr.com\/ru\/companies\/it_sense\/articles\/932054\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0433\u0430\u0439\u0434\u0430<\/a> \u043f\u043e Spring GraphQL, \u0433\u0434\u0435 \u043c\u044b \u0441 \u043d\u0443\u043b\u044f \u043f\u043e\u0434\u043d\u044f\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0438 GraphQL \u043a Spring Boot.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443\u0433\u043b\u0443\u0431\u0438\u043c\u0441\u044f \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0433\u043e API: \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0441\u0445\u0435\u043c\u0443 \u0441 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0438 \u0441\u0432\u044f\u0437\u044f\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0435\u0439, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0443\u0442\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0437\u0430\u0442\u0440\u043e\u043d\u0435\u043c \u0432\u0430\u0436\u043d\u044b\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041f\u043e\u0435\u0445\u0430\u043b\u0438!<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u043d\u043e\u0433\u043e @QueryMapping<\/h2>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u043c \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u0438 \u0438\u0445 \u043a\u043d\u0438\u0433:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/eb5\/cde\/4de\/eb5cde4ded443164d678a1bed8f629a2.png\" width=\"1600\" height=\"704\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/eb5\/cde\/4de\/eb5cde4ded443164d678a1bed8f629a2.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/eb5\/cde\/4de\/eb5cde4ded443164d678a1bed8f629a2.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 getAuthors \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0430\u0432\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0435\u0440\u043d\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u0438 \u0438\u0445 \u043a\u043d\u0438\u0433.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0432 \u0441\u0445\u0435\u043c\u0435 \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0442\u0438\u043f\u044b \u0438 \u043f\u043e\u0434\u0442\u0438\u043f\u044b (\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u043b\u044e\u0431\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0442\u0438\u043f).<\/p>\n<p>\u0412 \u0441\u0445\u0435\u043c\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438:<\/p>\n<pre><code class=\"java\">type Query {    helloWorld(text: String!): String!    \"\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435\u0445 \u0430\u0432\u0442\u043e\u0440\u043e\u0432\"    getAuthors(filter: Int): [Author!]! }  \"\u0410\u0432\u0442\u043e\u0440\" type Author {    \"id \u0430\u0432\u0442\u043e\u0440\u0430\"    id: ID!    \"\u0418\u043c\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    name: String!    \"\u0424\u0430\u043c\u0438\u043b\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    surname: String!    \"\u0414\u0435\u043d\u044c \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    birthday: String!    \"\u041a\u043d\u0438\u0433\u0438 \u0430\u0432\u0442\u043e\u0440\u0430\"    books: [Book!]! }  \"\u041a\u043d\u0438\u0433\u0430\" type Book {    \"id \u043a\u043d\u0438\u0433\u0438\"    id: ID!    \"\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043d\u0438\u0433\u0438\"    title: String!    \"\u0413\u043e\u0434 \u0438\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043d\u0438\u0433\u0438\"    year: Int!    \"\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043d\u0438\u0433\u0438\"    description: String! }<\/code><\/pre>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0441\u0445\u0435\u043c\u044b graphql:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"110\" width=\"110\">\n<p align=\"left\"><strong>SDL<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"110\" width=\"110\">\n<p align=\"left\">[Int!]<\/p>\n<\/td>\n<td>\n<p align=\"left\">null \u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"110\" width=\"110\">\n<p align=\"left\">[Int]!<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b (\u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f null \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435), \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"110\" width=\"110\">\n<p align=\"left\">[Int!]!<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b (null \u043d\u0435 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f) \u0438\u043b\u0438 \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 notNull:<\/p>\n<ul>\n<li>\n<p>\u0412 <a href=\"https:\/\/spec.graphql.org\/October2021\/#sec-Combining-List-and-Non-Null\" rel=\"noopener noreferrer nofollow\">\u0441\u043f\u0435\u043a\u0435<\/a> \u043e\u0442 \u043e\u043a\u0442\u044f\u0431\u0440\u044f 2021 \u0433\u043e\u0434\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0412 <a href=\"https:\/\/spec.graphql.org\/draft\/#sec-Combining-List-and-Non-Null\" rel=\"noopener noreferrer nofollow\">\u0434\u0440\u0430\u0444\u0442\u0435 \u0441\u043f\u0435\u043a\u0438<\/a> \u043e\u0442 2025 \u0433\u043e\u0434\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 record \u0434\u043b\u044f Author \u0438 Book:<\/p>\n<pre><code class=\"java\">public record Author(        int id,        String name,        String surname,        String birthday,        List&lt;Book&gt; books ) { }<\/code><\/pre>\n<pre><code class=\"java\">public record Book(        int id,        String title,        int year,        String description ) { }<\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0439\u0442\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440:<\/p>\n<pre><code class=\"java\">@Controller @RequiredArgsConstructor public class GraphQLController {     private final DataBaseService dataBaseService;     @QueryMapping    public List&lt;Author&gt; getAuthors(@Argument Integer filter) {        return dataBaseService.getAuthors(filter);    } }<\/code><\/pre>\n<p>\u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0435 \u043b\u0438 \u0432\u044b \u043e\u0431\u044a\u0435\u043a\u0442 Book \u0438\u043b\u0438 \u043d\u0435\u0442, \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 getAuthors:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/375\/d92\/4bf\/375d924bfab60089cb825dbe1a7e2bc9.png\" width=\"1572\" height=\"582\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/375\/d92\/4bf\/375d924bfab60089cb825dbe1a7e2bc9.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/375\/d92\/4bf\/375d924bfab60089cb825dbe1a7e2bc9.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c @SchemaMapping.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b3e\/626\/045\/b3e626045f099a4edca46cad183f1ac1.jpeg\" width=\"600\" height=\"400\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/b3e\/626\/045\/b3e626045f099a4edca46cad183f1ac1.jpeg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b3e\/626\/045\/b3e626045f099a4edca46cad183f1ac1.jpeg 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f @SchemaMapping \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u043c\u0438<\/h2>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438\u0437 <strong>record<\/strong> Author \u043f\u043e\u043b\u0435 books, \u0442.\u043a. graphql \u0435\u0433\u043e \u0441\u043c\u0430\u043f\u0438\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0444\u0438\u043b\u044c\u0442\u0440 \u043a books \u0432 \u0441\u0445\u0435\u043c\u0435 graphql:<\/p>\n<pre><code class=\"java\">\"\u0410\u0432\u0442\u043e\u0440\" type Author {    \"id \u0430\u0432\u0442\u043e\u0440\u0430\"    id: Int!    \"\u0418\u043c\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    name: String!    \"\u0424\u0430\u043c\u0438\u043b\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    surname: String!    \"\u0414\u0435\u043d\u044c \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    birthday: String!    \"\u041a\u043d\u0438\u0433\u0438 \u0430\u0432\u0442\u043e\u0440\u0430\"    books(id: Int): [Book!]! }<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043d\u0438\u0433 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435:<\/p>\n<pre><code class=\"java\">@SchemaMapping(field = \"books\", typeName = \"Author\") public List&lt;Book&gt; getBookForAuthor(@Argument Integer id, Author author) {    return dataBaseService.getBooks(id, author.id()); }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0432 \u043c\u0435\u0442\u043e\u0434 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442, \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b\u0437\u0432\u0430\u043d\u043e \u043f\u043e\u043b\u0435.<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 getAuthors \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 3 \u0430\u0432\u0442\u043e\u0440\u0430, \u043c\u0435\u0442\u043e\u0434 getBookForAuthor \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d 3 \u0440\u0430\u0437\u0430 &#8212; \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0430\u0432\u0442\u043e\u0440\u0430:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ac8\/6e4\/aff\/ac86e4affe72807e82b9f2b3eae1f6e6.png\" width=\"1540\" height=\"728\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/ac8\/6e4\/aff\/ac86e4affe72807e82b9f2b3eae1f6e6.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ac8\/6e4\/aff\/ac86e4affe72807e82b9f2b3eae1f6e6.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<div class=\"floating-image\">\n<figure class=\"float full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/da8\/86c\/697\/da886c69724c6a42d584469f288be5ef.png\" width=\"1600\" height=\"1600\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/da8\/86c\/697\/da886c69724c6a42d584469f288be5ef.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/da8\/86c\/697\/da886c69724c6a42d584469f288be5ef.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441: \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0442\u0440\u0435\u0445\u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043d\u0438\u0433\u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u0437\u0430 \u043e\u0434\u0438\u043d \u0440\u0430\u0437?\u00a0<\/p>\n<\/div>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>@BatchMapping (\u0438\u043c\u0435\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f);<\/p>\n<\/li>\n<li>\n<p>DataLoader.<\/p>\n<\/li>\n<\/ul>\n<h2>@BatchMapping<\/h2>\n<p>@BatchMapping &#8212; \u044d\u0442\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u043a\u0435\u0442\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d \u0432 \u0446\u0435\u043b\u044f\u0445 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 GraphQL.<\/p>\n<p><strong>\u0414\u0430\u043d\u043d\u0430\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438.\u00a0<\/strong><\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443\u0434\u0430\u043b\u0438\u0442\u0435 \u0444\u0438\u043b\u044c\u0442\u0440 \u0443 \u043f\u043e\u043b\u044f books \u0438\u0437 \u0441\u0445\u0435\u043c\u044b:<\/p>\n<pre><code class=\"java\">\"\u0410\u0432\u0442\u043e\u0440\" type Author {    \"id \u0430\u0432\u0442\u043e\u0440\u0430\"    id: UUID!    \"\u0418\u043c\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    name: String!    \"\u0424\u0430\u043c\u0438\u043b\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    surname: String!    \"\u0414\u0435\u043d\u044c \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    birthday: String!    \"\u041a\u043d\u0438\u0433\u0438 \u0430\u0432\u0442\u043e\u0440\u0430\"    books: [Book!]! }<\/code><\/pre>\n<p>\u0417\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 SchemaMapping \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0438 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 BatchMapping:<\/p>\n<pre><code class=\"java\">@BatchMapping(field = \"books\", typeName = \"Author\") public Map&lt;Author, List&lt;Book&gt;&gt; getBooks(List&lt;Author&gt; authorsIds) {    return dataBaseService.dataload(authorsIds);\/\/\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430 \u043e\u0434\u0438\u043d \u043f\u043e\u0445\u043e\u0434 \u0432 \u0411\u0414 }<\/code><\/pre>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/754\/803\/75c\/75480375c3d5fa5178951b549c0b9c6a.png\" width=\"1550\" height=\"724\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/754\/803\/75c\/75480375c3d5fa5178951b549c0b9c6a.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/754\/803\/75c\/75480375c3d5fa5178951b549c0b9c6a.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h2>DataLoader<\/h2>\n<p>\u0412\u0435\u0440\u043d\u0438\u0442\u0435 \u0444\u0438\u043b\u044c\u0442\u0440 \u0432 \u043f\u043e\u043b\u0435 books:<\/p>\n<pre><code class=\"java\">\"\u0410\u0432\u0442\u043e\u0440\" type Author {    \"id \u0430\u0432\u0442\u043e\u0440\u0430\"    id: UUID!    \"\u0418\u043c\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    name: String!    \"\u0424\u0430\u043c\u0438\u043b\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    surname: String!    \"\u0414\u0435\u043d\u044c \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    birthday: String!    \"\u041a\u043d\u0438\u0433\u0438 \u0430\u0432\u0442\u043e\u0440\u0430\"    books(id: Int): [Book!]! }<\/code><\/pre>\n<p>\u0423\u0434\u0430\u043b\u0438\u0442\u0435 BatchMapping \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 DataLoader \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 SchemaMapping:<\/p>\n<pre><code class=\"java\">public GraphQLController(BatchLoaderRegistry registry, GraphQLClient graphQLClient, DataBaseService dataBaseService) {    RegistrationSpec&lt;Author, List&lt;Book&gt;&gt; spec = registry.forName(\"loaderBook\");    spec.registerMappedBatchLoader((authorIds, env) -&gt; {                Integer id = null;                if (!CollectionUtils.isEmpty(env.getKeyContextsList())) {                    id = (Integer) env.getKeyContextsList().getFirst();                }        Map&lt;Author, List&lt;Book&gt;&gt;  thingsInSites = dataBaseService.testDataload(id);        return Mono.just(thingsInSites);    });    this.graphQLClient = graphQLClient;    this.dataBaseService = dataBaseService; }<\/code><\/pre>\n<pre><code class=\"java\">@SchemaMapping(field = \"books\", typeName = \"Author\") public CompletableFuture&lt;List&lt;Book&gt;&gt; getBookForAuthor(@Argument Integer id, Author author,                                                      DataLoader&lt;Author, List&lt;Book&gt;&gt; loaderBook) {    return loaderBook.load(author, id); }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b \u0443 \u0432\u0430\u0441 \u043d\u0435 \u0431\u044b\u043b\u043e @Argument, \u0442\u043e \u0432 load \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e Author.\u00a0<\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0439\u0442\u0435 Equals \u0438 HashCode \u0434\u043b\u044f Author.<\/p>\n<h2>DataFetchingEnvironment<\/h2>\n<p>DataFetchingEnvironment &#8212; \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 GraphQL. \u041e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0435, \u0441\u0445\u0435\u043c\u0435, \u0442\u0438\u043f\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u0434\u0435\u0442\u0430\u043b\u044f\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.\u00a0<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u043d\u0430\u0448\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p>\u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443,<\/p>\n<pre><code class=\"java\">@QueryMapping public List&lt;Author&gt; getAuthors (@Argument Integer filter, DataFetchingEnvironment environment) ...<\/code><\/pre>\n<p>\u0427\u0435\u0440\u0435\u0437 DataFetchingEnvironment, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u043b\u0438\u0431\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u0435\u0436\u0434\u0443 QueryMapping \u0438 SchemaMapping:<\/p>\n<pre><code class=\"java\">(DataFetchingEnvironment) environment.getGraphQlContext().put(        \"key\", value);<\/code><\/pre>\n<pre><code class=\"java\"> if (environment.getGraphQlContext().hasKey(\"key\")) {        Object info = environment.getGraphQlContext().get(\"key\");    } <\/code><\/pre>\n<p>\u0427\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 @SchemaMapping, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443: \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0443\u0437\u043b\u0430 Author.\u00a0<\/p>\n<h2>\u0412\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0430: \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435<\/h2>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u0441 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043e\u0448\u0438\u0431\u043e\u043a, \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u0441 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c\u0438 \u0441\u043a\u0430\u043b\u044f\u0440\u0430\u043c\u0438 \u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430\u043c\u0438. \u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u0438 union-\u0442\u0438\u043f\u043e\u0432, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u044b \u0438 \u043a\u043b\u0438\u0435\u043d\u0442 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a GraphQL-\u0441\u0435\u0440\u0432\u0438\u0441\u0443.<\/p>\n<p><em>\u0410 \u043f\u043e\u043a\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u043a\u0430\u043a\u0438\u0435 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0442\u0435\u043c \u0432\u0430\u043c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0438\u043b\u0438 \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0432 \u0432\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445?<\/em><\/p>\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\/937128\/\"> https:\/\/habr.com\/ru\/articles\/937128\/<\/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>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0414\u043c\u0438\u0442\u0440\u0438\u0439, \u044f \u0431\u044d\u043a\u0435\u043d\u0434-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 <a href=\"https:\/\/t.me\/it_sense\" rel=\"noopener noreferrer nofollow\">SENSE<\/a> \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 10 \u043b\u0435\u0442 \u043f\u0438\u0448\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043d\u0430 Java. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u2013 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 <a href=\"https:\/\/habr.com\/ru\/companies\/it_sense\/articles\/932054\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0433\u0430\u0439\u0434\u0430<\/a> \u043f\u043e Spring GraphQL, \u0433\u0434\u0435 \u043c\u044b \u0441 \u043d\u0443\u043b\u044f \u043f\u043e\u0434\u043d\u044f\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0438 GraphQL \u043a Spring Boot.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443\u0433\u043b\u0443\u0431\u0438\u043c\u0441\u044f \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0433\u043e API: \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0441\u0445\u0435\u043c\u0443 \u0441 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0438 \u0441\u0432\u044f\u0437\u044f\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0435\u0439, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0443\u0442\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0437\u0430\u0442\u0440\u043e\u043d\u0435\u043c \u0432\u0430\u0436\u043d\u044b\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041f\u043e\u0435\u0445\u0430\u043b\u0438!<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u043d\u043e\u0433\u043e @QueryMapping<\/h2>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u043c \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u0438 \u0438\u0445 \u043a\u043d\u0438\u0433:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 getAuthors \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0430\u0432\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0435\u0440\u043d\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u0438 \u0438\u0445 \u043a\u043d\u0438\u0433.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0432 \u0441\u0445\u0435\u043c\u0435 \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0442\u0438\u043f\u044b \u0438 \u043f\u043e\u0434\u0442\u0438\u043f\u044b (\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u043b\u044e\u0431\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0442\u0438\u043f).<\/p>\n<p>\u0412 \u0441\u0445\u0435\u043c\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438:<\/p>\n<pre><code class=\"java\">type Query {    helloWorld(text: String!): String!    \"\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435\u0445 \u0430\u0432\u0442\u043e\u0440\u043e\u0432\"    getAuthors(filter: Int): [Author!]! }  \"\u0410\u0432\u0442\u043e\u0440\" type Author {    \"id \u0430\u0432\u0442\u043e\u0440\u0430\"    id: ID!    \"\u0418\u043c\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    name: String!    \"\u0424\u0430\u043c\u0438\u043b\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    surname: String!    \"\u0414\u0435\u043d\u044c \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    birthday: String!    \"\u041a\u043d\u0438\u0433\u0438 \u0430\u0432\u0442\u043e\u0440\u0430\"    books: [Book!]! }  \"\u041a\u043d\u0438\u0433\u0430\" type Book {    \"id \u043a\u043d\u0438\u0433\u0438\"    id: ID!    \"\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043d\u0438\u0433\u0438\"    title: String!    \"\u0413\u043e\u0434 \u0438\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043d\u0438\u0433\u0438\"    year: Int!    \"\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043d\u0438\u0433\u0438\"    description: String! }<\/code><\/pre>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0441\u0445\u0435\u043c\u044b graphql:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"110\" width=\"110\">\n<p align=\"left\"><strong>SDL<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"110\" width=\"110\">\n<p align=\"left\">[Int!]<\/p>\n<\/td>\n<td>\n<p align=\"left\">null \u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"110\" width=\"110\">\n<p align=\"left\">[Int]!<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b (\u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f null \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435), \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"110\" width=\"110\">\n<p align=\"left\">[Int!]!<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b (null \u043d\u0435 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f) \u0438\u043b\u0438 \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 notNull:<\/p>\n<ul>\n<li>\n<p>\u0412 <a href=\"https:\/\/spec.graphql.org\/October2021\/#sec-Combining-List-and-Non-Null\" rel=\"noopener noreferrer nofollow\">\u0441\u043f\u0435\u043a\u0435<\/a> \u043e\u0442 \u043e\u043a\u0442\u044f\u0431\u0440\u044f 2021 \u0433\u043e\u0434\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0412 <a href=\"https:\/\/spec.graphql.org\/draft\/#sec-Combining-List-and-Non-Null\" rel=\"noopener noreferrer nofollow\">\u0434\u0440\u0430\u0444\u0442\u0435 \u0441\u043f\u0435\u043a\u0438<\/a> \u043e\u0442 2025 \u0433\u043e\u0434\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 record \u0434\u043b\u044f Author \u0438 Book:<\/p>\n<pre><code class=\"java\">public record Author(        int id,        String name,        String surname,        String birthday,        List&lt;Book&gt; books ) { }<\/code><\/pre>\n<pre><code class=\"java\">public record Book(        int id,        String title,        int year,        String description ) { }<\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0439\u0442\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440:<\/p>\n<pre><code class=\"java\">@Controller @RequiredArgsConstructor public class GraphQLController {     private final DataBaseService dataBaseService;     @QueryMapping    public List&lt;Author&gt; getAuthors(@Argument Integer filter) {        return dataBaseService.getAuthors(filter);    } }<\/code><\/pre>\n<p>\u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0435 \u043b\u0438 \u0432\u044b \u043e\u0431\u044a\u0435\u043a\u0442 Book \u0438\u043b\u0438 \u043d\u0435\u0442, \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 getAuthors:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c @SchemaMapping.<\/p>\n<figure class=\"full-width\"><\/figure>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f @SchemaMapping \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u043c\u0438<\/h2>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438\u0437 <strong>record<\/strong> Author \u043f\u043e\u043b\u0435 books, \u0442.\u043a. graphql \u0435\u0433\u043e \u0441\u043c\u0430\u043f\u0438\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0444\u0438\u043b\u044c\u0442\u0440 \u043a books \u0432 \u0441\u0445\u0435\u043c\u0435 graphql:<\/p>\n<pre><code class=\"java\">\"\u0410\u0432\u0442\u043e\u0440\" type Author {    \"id \u0430\u0432\u0442\u043e\u0440\u0430\"    id: Int!    \"\u0418\u043c\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    name: String!    \"\u0424\u0430\u043c\u0438\u043b\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    surname: String!    \"\u0414\u0435\u043d\u044c \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    birthday: String!    \"\u041a\u043d\u0438\u0433\u0438 \u0430\u0432\u0442\u043e\u0440\u0430\"    books(id: Int): [Book!]! }<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043d\u0438\u0433 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435:<\/p>\n<pre><code class=\"java\">@SchemaMapping(field = \"books\", typeName = \"Author\") public List&lt;Book&gt; getBookForAuthor(@Argument Integer id, Author author) {    return dataBaseService.getBooks(id, author.id()); }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0432 \u043c\u0435\u0442\u043e\u0434 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442, \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b\u0437\u0432\u0430\u043d\u043e \u043f\u043e\u043b\u0435.<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 getAuthors \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 3 \u0430\u0432\u0442\u043e\u0440\u0430, \u043c\u0435\u0442\u043e\u0434 getBookForAuthor \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d 3 \u0440\u0430\u0437\u0430 &#8212; \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0430\u0432\u0442\u043e\u0440\u0430:<\/p>\n<figure class=\"full-width\"><\/figure>\n<div class=\"floating-image\">\n<figure class=\"float full-width\"><\/figure>\n<p>\u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441: \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0442\u0440\u0435\u0445\u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043d\u0438\u0433\u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u0437\u0430 \u043e\u0434\u0438\u043d \u0440\u0430\u0437?\u00a0<\/p>\n<\/div>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>@BatchMapping (\u0438\u043c\u0435\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f);<\/p>\n<\/li>\n<li>\n<p>DataLoader.<\/p>\n<\/li>\n<\/ul>\n<h2>@BatchMapping<\/h2>\n<p>@BatchMapping &#8212; \u044d\u0442\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u043a\u0435\u0442\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d \u0432 \u0446\u0435\u043b\u044f\u0445 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 GraphQL.<\/p>\n<p><strong>\u0414\u0430\u043d\u043d\u0430\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438.\u00a0<\/strong><\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443\u0434\u0430\u043b\u0438\u0442\u0435 \u0444\u0438\u043b\u044c\u0442\u0440 \u0443 \u043f\u043e\u043b\u044f books \u0438\u0437 \u0441\u0445\u0435\u043c\u044b:<\/p>\n<pre><code class=\"java\">\"\u0410\u0432\u0442\u043e\u0440\" type Author {    \"id \u0430\u0432\u0442\u043e\u0440\u0430\"    id: UUID!    \"\u0418\u043c\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    name: String!    \"\u0424\u0430\u043c\u0438\u043b\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    surname: String!    \"\u0414\u0435\u043d\u044c \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    birthday: String!    \"\u041a\u043d\u0438\u0433\u0438 \u0430\u0432\u0442\u043e\u0440\u0430\"    books: [Book!]! }<\/code><\/pre>\n<p>\u0417\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 SchemaMapping \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0438 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 BatchMapping:<\/p>\n<pre><code class=\"java\">@BatchMapping(field = \"books\", typeName = \"Author\") public Map&lt;Author, List&lt;Book&gt;&gt; getBooks(List&lt;Author&gt; authorsIds) {    return dataBaseService.dataload(authorsIds);\/\/\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430 \u043e\u0434\u0438\u043d \u043f\u043e\u0445\u043e\u0434 \u0432 \u0411\u0414 }<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<h2>DataLoader<\/h2>\n<p>\u0412\u0435\u0440\u043d\u0438\u0442\u0435 \u0444\u0438\u043b\u044c\u0442\u0440 \u0432 \u043f\u043e\u043b\u0435 books:<\/p>\n<pre><code class=\"java\">\"\u0410\u0432\u0442\u043e\u0440\" type Author {    \"id \u0430\u0432\u0442\u043e\u0440\u0430\"    id: UUID!    \"\u0418\u043c\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    name: String!    \"\u0424\u0430\u043c\u0438\u043b\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    surname: String!    \"\u0414\u0435\u043d\u044c \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430\"    birthday: String!    \"\u041a\u043d\u0438\u0433\u0438 \u0430\u0432\u0442\u043e\u0440\u0430\"    books(id: Int): [Book!]! }<\/code><\/pre>\n<p>\u0423\u0434\u0430\u043b\u0438\u0442\u0435 BatchMapping \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 DataLoader \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 SchemaMapping:<\/p>\n<pre><code class=\"java\">public GraphQLController(BatchLoaderRegistry registry, GraphQLClient graphQLClient, DataBaseService dataBaseService) {    RegistrationSpec&lt;Author, List&lt;Book&gt;&gt; spec = registry.forName(\"loaderBook\");    spec.registerMappedBatchLoader((authorIds, env) -&gt; {                Integer id = null;                if (!CollectionUtils.isEmpty(env.getKeyContextsList())) {                    id = (Integer) env.getKeyContextsList().getFirst();                }        Map&lt;Author, List&lt;Book&gt;&gt;  thingsInSites = dataBaseService.testDataload(id);        return Mono.just(thingsInSites);    });    this.graphQLClient = graphQLClient;    this.dataBaseService = dataBaseService; }<\/code><\/pre>\n<pre><code class=\"java\">@SchemaMapping(field = \"books\", typeName = \"Author\") public CompletableFuture&lt;List&lt;Book&gt;&gt; getBookForAuthor(@Argument Integer id, Author author,                                                      DataLoader&lt;Author, List&lt;Book&gt;&gt; loaderBook) {    return loaderBook.load(author, id); }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b \u0443 \u0432\u0430\u0441 \u043d\u0435 \u0431\u044b\u043b\u043e @Argument, \u0442\u043e \u0432 load \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e Author.\u00a0<\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0439\u0442\u0435 Equals \u0438 HashCode \u0434\u043b\u044f Author.<\/p>\n<h2>DataFetchingEnvironment<\/h2>\n<p>DataFetchingEnvironment &#8212; \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 GraphQL. \u041e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0435, \u0441\u0445\u0435\u043c\u0435, \u0442\u0438\u043f\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u0434\u0435\u0442\u0430\u043b\u044f\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.\u00a0<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u043d\u0430\u0448\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p>\u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443,<\/p>\n<pre><code class=\"java\">@QueryMapping public List&lt;Author&gt; getAuthors (@Argument Integer filter, DataFetchingEnvironment environment) ...<\/code><\/pre>\n<p>\u0427\u0435\u0440\u0435\u0437 DataFetchingEnvironment, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u043b\u0438\u0431\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u0435\u0436\u0434\u0443 QueryMapping \u0438 SchemaMapping:<\/p>\n<pre><code class=\"java\">(DataFetchingEnvironment) environment.getGraphQlContext().put(        \"key\", value);<\/code><\/pre>\n<pre><code class=\"java\"> if (environment.getGraphQlContext().hasKey(\"key\")) {        Object info = environment.getGraphQlContext().get(\"key\");    } <\/code><\/pre>\n<p>\u0427\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 @SchemaMapping, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443: \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0443\u0437\u043b\u0430 Author.\u00a0<\/p>\n<h2>\u0412\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0430: \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435<\/h2>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u0441 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043e\u0448\u0438\u0431\u043e\u043a, \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u0441 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c\u0438 \u0441\u043a\u0430\u043b\u044f\u0440\u0430\u043c\u0438 \u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430\u043c\u0438. \u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u0438 union-\u0442\u0438\u043f\u043e\u0432, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u044b \u0438 \u043a\u043b\u0438\u0435\u043d\u0442 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a GraphQL-\u0441\u0435\u0440\u0432\u0438\u0441\u0443.<\/p>\n<p><em>\u0410 \u043f\u043e\u043a\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u043a\u0430\u043a\u0438\u0435 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0442\u0435\u043c \u0432\u0430\u043c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0438\u043b\u0438 \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0432 \u0432\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445?<\/em><\/p>\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\/937128\/\"> https:\/\/habr.com\/ru\/articles\/937128\/<\/a><br \/><\/br><\/br><\/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-470736","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/470736","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=470736"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/470736\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=470736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=470736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=470736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}