Commit 2a6710eb by Tuomas Riihimäki

Fix graphql user response value

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