When making queries, the info.context.user returns a correct user.
However, then making the mutation, the same call to the info.context.user return AnonymousUser
Any suggestions what is going on?
As far as I can tell, we do not handle Mutations and Queries differently when it comes to their context. It should be calling get_context regardless.
Do you have more context you can share, or the minimum code it takes to reproduce the problem?
Hey,
It was my bad configuration of apollo-client and JWT middleware for authentication.
Thanks for great job guys!
L
Could you please provide further information as to where the configuration issue was?
I'm currently running into the exact same issue.
I see that this question still seems to be popular given the number of likes from the previous comment.
To anyone experiencing a similar issue:
graphql.error.located_error.GraphQLLocatedError: 'NoneType' object has no attribute 'context'
it may be caused by the ordering of the parameters.
Graphene always stores the mutation context, and hence the user transitively, in the second non-default parameter it receives.
Using,
def mutate(root, info, **kwargs)
The user is retrieved by calling info.context.user.
Using,
def mutate(info, root, **kwargs)
You would retrieve the user using root.context.user.
Always ensure that your parameter ordering is consistent throughout your function definitions.
Most helpful comment
Could you please provide further information as to where the configuration issue was?
I'm currently running into the exact same issue.