strawberry-django-jwt icon indicating copy to clipboard operation
strawberry-django-jwt copied to clipboard

field `refreshToken` is not async safe

Open nrbnlulu opened this issue 1 year ago • 3 comments

consider this query

obtainPayload {
    payload {
      origIat
      exp
      username
    }
    refreshExpiresIn
    # no refresh token here
    token
  }

Works fine.
But this one:

mutation obtainJWT {
  obtainPayload {
    payload {
      origIat
      exp
      username
    }
    refreshExpiresIn
    refreshToken //  <<<
    token
  }
}

gives this error

"errors": [
    {
      "message": "You cannot call this from an async context - use a thread or sync_to_async.",
      "locations": [
        {
          "line": 11,
          "column": 7
        }
      ],
    }
]

This is possibly the line. https://github.com/KundaPanda/strawberry-django-jwt/blob/17d520efcb1f2e2cfefc2744d283b7c93ea8d540/strawberry_django_jwt/refresh_token/shortcuts.py#L24

nrbnlulu avatar Jul 21 '22 08:07 nrbnlulu