Answer the question
In order to leave comments, you need to log in
How to optimize server response (Spring boot 2 API) in JSON format?
Hello. Thank you for a minute.
It is necessary to return a selection from the server according to data from different tables. And glue somehow into a single whole entity. Example on quests:
There are quests in them teams and participants. How do I return a new entity (NOT quests, NOT teams, NOT participants). I have a quest (entity) like this:
{
"id": 1,
"name": "quest1",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ornare pretium tortor, et convallis nibh condimentum et. Vivamus nec aliquet nulla, consectetur commodo tortor. Mauris purus odio, imperdiet a sollicitudin sed, ornare id lorem. Mauris bibendum, orci eu aliquam ullamcorper, erat tortor interdum libero, et porttitor lectus dui vitae risus. Fusce lacinia metus et metus ornare, non faucibus metus dapibus. Proin venenatis, augue nec feugiat tincidunt, dolor orci ultrices lorem, eget accumsan sapien ex bibendum ante. Integer bibendum velit sit amet nibh maximus, sed laoreet sapien tincidunt. Nullam tristique erat sit amet augue ultricies blandit. Nunc augue lectus, fringilla sed lobortis vitae, faucibus non magna.\n Etiam sed luctus ante, vitae porttitor orci. Integer at risus maximus, porttitor justo quis, viverra nunc. In quis arcu dolor. Etiam accumsan tellus sit amet odio dictum luctus. Donec at finibus diam. Phasellus auctor ante ut dolor eleifend, nec iaculis felis volutpat. Duis vestibulum, risus.",
"stages": [
{
"id": 1,
"name": "stage1",
"task": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam malesuada, dolor quis euismod scelerisque, lacus.",
"points": 10,
"dataTimeStart": "2018-05-29T00:58:24.602+0000",
"usersStages": [
{
"id": 2,
"dataTimeEnd": "2018-05-29T00:58:24.602+0000"
}
]
},
{
"id": 2,
"name": "stage2",
"task": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque ac maximus nisl. Fusce sem libero, laoreet a congue vel, sollicitudin.",
"points": 15,
"dataTimeStart": "2018-05-29T00:58:24.602+0000",
"usersStages": [
{
"id": 1,
"dataTimeEnd": "2018-05-29T00:58:24.602+0000"
}
]
},
{
"id": 3,
"name": "stage3",
"task": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam fermentum lorem quis enim tempus, vel gravida erat.",
"points": 10,
"dataTimeStart": "2018-05-29T00:58:24.602+0000",
"usersStages": []
}
],
"teams": [
{
"id": 1,
"name": "team1"
},
{
"id": 2,
"name": "team2"
},
{
"id": 3,
"name": "team3"
},
{
"id": 4,
"name": "team4"
}
]
},
[
"id" : 1,
"name" : "quest1",
"countTeams" : 3,
"countStages" : 4,
"check" : 1
]
Answer the question
In order to leave comments, you need to log in
class Response{
private Integer id;
private String quest1;,
private Integer countTeams;
private Integer countStages;
private Integer check;
}
In your case, GraphQL would probably be suitable - here is the introductory article https://habr.com/post/326986/
And here is the implementation in java - https://github.com/graphql-java/graphql-java
And here is the article for spring - www.baeldung.com/spring-graphql
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question