You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AuthContext context = env.getContext(); Link newLink = new Link(url, description, context.getUser().getId());
I do not get null on context varible, but I get a null on context.getUser()
The text was updated successfully, but these errors were encountered:
JonathanSum
changed the title
Returned null on n, DataFetchingEnvironment .getUser() in Mutation class
Returned null on DataFetchingEnvironment .getUser() in Mutation class
Mar 4, 2018
I'm working on rewriting the tutorial in pure graphql-java (without graphql-java-tools), and this is what I'd recommend you try as well. the tutorial is very outdated as it is.
For the time being, your issue is very likely either because the browser doesn't send the user ID (in the Authorization header) at all or, if it does, it doesn't match the ID in Mongo.
Put a break point in createContext method in GraphQLEndpoint and inspect what happens.
The tutorial explains the code you need to add to the client to start sending the Authorization header, so make sure you followed that. otherwise, just make sure the ID it sends matches what you have in Mongo.
AuthContext context = env.getContext(); Link newLink = new Link(url, description, context.getUser().getId());
I do not get null on context varible, but I get a null on context.getUser()
code:https://github.com/howtographql/graphql-java/blob/master/src/main/java/com/howtographql/hackernews/Mutation.java
or my code:
https://github.com/JonathanSum/myOwnJavaGraphqlStarterKit/blob/master/src/main/java/com/howtographql/hackernews/Mutation.java
The text was updated successfully, but these errors were encountered: