enabled GraphiQL and created base entities
This commit is contained in:
parent
daf770f5ee
commit
2ecf7366c1
@ -0,0 +1,27 @@
|
||||
package ru.dragonestia.picker.controller.graphql;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.graphql.data.method.annotation.QueryMapping;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import ru.dragonestia.picker.controller.graphql.entity.EntityNode;
|
||||
import ru.dragonestia.picker.service.NodeService;
|
||||
import ru.dragonestia.picker.service.RoomService;
|
||||
import ru.dragonestia.picker.service.UserService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
public class GraphqlController {
|
||||
|
||||
private final NodeService nodeService;
|
||||
private final RoomService roomService;
|
||||
private final UserService userService;
|
||||
|
||||
@QueryMapping
|
||||
List<EntityNode> allNodes() {
|
||||
return nodeService.all().stream()
|
||||
.map(EntityNode::new)
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package ru.dragonestia.picker.controller.graphql.entity;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import ru.dragonestia.picker.model.Node;
|
||||
|
||||
public class EntityNode {
|
||||
|
||||
private final Node node;
|
||||
|
||||
public EntityNode(Node node) {
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
public @NotNull String getId() {
|
||||
return node.getIdentifier();
|
||||
}
|
||||
|
||||
public @NotNull String getMethod() {
|
||||
return node.getPickingMethod().name();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package ru.dragonestia.picker.controller.graphql.entity;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import ru.dragonestia.picker.model.Room;
|
||||
|
||||
public class EntityRoom {
|
||||
|
||||
private final Room room;
|
||||
|
||||
public EntityRoom(@NotNull Room room) {
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
public @NotNull String getId() {
|
||||
return room.getIdentifier();
|
||||
}
|
||||
|
||||
public @NotNull String getNodeId() {
|
||||
return room.getNodeIdentifier();
|
||||
}
|
||||
|
||||
public int getSlots() {
|
||||
return room.getMaxSlots();
|
||||
}
|
||||
|
||||
public @NotNull String getPayload() {
|
||||
return room.getPayload();
|
||||
}
|
||||
|
||||
public boolean isLocked() {
|
||||
return room.isLocked();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package ru.dragonestia.picker.controller.graphql.entity;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import ru.dragonestia.picker.model.User;
|
||||
|
||||
public class EntityUser {
|
||||
|
||||
private final User user;
|
||||
|
||||
public EntityUser(@NotNull User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public @NotNull String getId() {
|
||||
return user.getIdentifier();
|
||||
}
|
||||
}
|
||||
@ -15,3 +15,8 @@ springdoc:
|
||||
swagger-ui:
|
||||
path: /api-docs-ui
|
||||
default-models-expand-depth: -1
|
||||
|
||||
spring:
|
||||
graphql:
|
||||
graphiql:
|
||||
enabled: true
|
||||
|
||||
24
server/src/main/resources/graphql/schema.graphqls
Normal file
24
server/src/main/resources/graphql/schema.graphqls
Normal file
@ -0,0 +1,24 @@
|
||||
type Query {
|
||||
allNodes: [Node]
|
||||
nodeById(id: String!): Node
|
||||
allRooms(nodeId: String!): [Room]
|
||||
roomById(nodeId: String!, roomId: String!): Room
|
||||
roomUsers(nodeId: String!, roomId: String!): [User]
|
||||
}
|
||||
|
||||
type Node {
|
||||
id: String!
|
||||
method: String!
|
||||
}
|
||||
|
||||
type Room {
|
||||
id: String!
|
||||
nodeId: String!
|
||||
slots: Int!
|
||||
payload: String!
|
||||
locked: Boolean!
|
||||
}
|
||||
|
||||
type User {
|
||||
id: String!
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user