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
{{ message }}
This repository has been archived by the owner on Nov 16, 2018. It is now read-only.
The current mutation seems to not be working with graphene 2.0
@staticmethod
def mutate(root, args, context, info):
if not context.user.is_authenticated():
return CreateMessageMutation(status=403)
message = args.get('message', '').strip()
# Here we would usually use Django forms to validate the input
if not message:
return CreateMessageMutation(
status=400,
formErrors=json.dumps(
{'message': ['Please enter a message.']}))
obj = models.Message.objects.create(
user=context.user, message=message
)
return CreateMessageMutation(status=200, message=obj)
Since the version 2.0 now only receives as arguments for mutate(root, info, **args) where can we get now the context info so that context.user.is_authenticated() could work?
The text was updated successfully, but these errors were encountered:
defmutate(self, info, **kwargs):
ifnotinfo.context.user.is_authenticated:
returnCreateMessage(status=403)
message=kwargs.get('message', '').strip()
# Here we would usually use Django forms to validate the inputifnotmessage:
returnCreateMessage(
status=400,
formErrors=json.dumps(
{'message': ['Please enter a message.']}))
obj=models.Message.objects.create(
user=info.context.user, message=message
)
returnCreateMessage(status=200, message=obj)
You have to change the tests then too...
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The current mutation seems to not be working with graphene 2.0
Since the version 2.0 now only receives as arguments for mutate(root, info, **args) where can we get now the context info so that context.user.is_authenticated() could work?
The text was updated successfully, but these errors were encountered: