Commit 2a6710eb by Tuomas Riihimäki

Fix graphql user response value

1 parent ec627810
......@@ -31,8 +31,7 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import static graphql.Scalars.*;
import static graphql.schema.GraphQLArgument.newArgument;
......@@ -577,8 +576,8 @@ public class MoyaGraphQLServlet extends HttpServlet {
private GraphQLFieldDefinition getSingleUserQuery(GraphQLBuilder builder) {
return newFieldDefinition()
.name("user")
.argument(newArgument().name("id").type(GraphQLInt).description("Id of the global user object. If id is 0, currently logged in user is used"))
.type(builder.typeFor(User.class))
.argument(newArgument().name("id").defaultValue(null).type(GraphQLInt).description("Id of the global user object. If id is 0, currently logged in user is used"))
.type(builder.typeFor(EventUser.class))
.dataFetcher(environment -> {
Integer id = environment.getArgument("userId");
EventUser user;
......@@ -590,7 +589,7 @@ public class MoyaGraphQLServlet extends HttpServlet {
if (user == null) {
throw new NullPointerException("User not found with id " + id);
}
return user.getUser();
return user;
}).build();
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!