File: faq.md

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 (39 lines) | stat: -rw-r--r-- 1,031 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
title: Frequently Asked Questions
---

# Frequently Asked Questions (FAQ)

## How to access Django request object in resolvers?

The request object is accessible via the `get_request` method.

```python
from strawberry_django.utils.requests import get_request

def resolver(root, info: Info):
    request = get_request(info)
```

## How to access the current user object in resolvers?

The current user object is accessible via the `get_current_user` method.

```python
from strawberry_django.auth.utils import get_current_user

def resolver(root, info: Info):
    current_user = get_current_user(info)
```

## Autocompletion with editors

Some editors like VSCode may not be able to resolve symbols and types without explicit `strawberry.django` import. Adding following line to code fixes that problem.

```python
import strawberry.django
```

## Example project?

See complete Django project from github repository folder [examples/django](https://github.com/strawberry-graphql/strawberry-django/tree/main/examples/django).