Search code examples
djangographene-django

How to access django request using graphene mutation info


I get this error 'WSGIRequest' object has no attribute 'request'

PS: snippet is a truncated. Error is coming from info.context.request

  class Arguments:
    input = ForgotPasswordInput()

  ok = graphene.Boolean()
  message = graphene.String()

  @staticmethod
  def mutate(root, info, input=None):
    try:
      user = User.objects.get(email=input.get('email'))
      current_site = get_current_site(info.context.request)```


Solution

  • Here the info.context itself the request object. So, it should be as,

    current_site = get_current_site(info.context)
                                   ^^^^^^^^^^^^^^