File: requests.py

package info (click to toggle)
strawberry-graphql-django 0.62.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,968 kB
  • sloc: python: 27,530; sh: 17; makefile: 16
file content (17 lines) | stat: -rw-r--r-- 445 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from django.http.request import HttpRequest
from strawberry.types import Info


def get_request(info: Info) -> HttpRequest:
    """Return the request from Info.

    description:
    Return the request object for both WSGI and ASGI implementations.
    It tends to move based on the environment.
    """
    try:
        request = info.context.request
    except AttributeError:
        request = info.context.get("request")

    return request