Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returned null on DataFetchingEnvironment .getUser() in Mutation class #4

Open
JonathanSum opened this issue Mar 4, 2018 · 2 comments

Comments

@JonathanSum
Copy link

JonathanSum commented Mar 4, 2018

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

@JonathanSum JonathanSum changed the title Returned null on n, DataFetchingEnvironment .getUser() in Mutation class Returned null on DataFetchingEnvironment .getUser() in Mutation class Mar 4, 2018
@kaqqao
Copy link
Collaborator

kaqqao commented Mar 5, 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.

@JonathanSum
Copy link
Author

JonathanSum commented Mar 11, 2018

All right. I will wait for your next tutorial. thx for writing the new tutorial anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants