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 40 41 42 43
|
---
title: Views
---
# Serving the API
Strawberry works both with ASGI (async) and WSGI (sync). This integration
supports both ways of serving django.
ASGI is the best way to enjoy everything that strawberry has to offer and
is highly recommended unless you can't for some reason. By using WSGI
you will be missing support for some interesting features, such as
[Data Loaders](https://strawberry.rocks/docs/guides/dataloaders).
# Serving as ASGI (async)
Expose the strawberry API when using ASGI by setting your urls.py like this:
```python title="urls.py"
from django.urls import path
from strawberry.django.views import AsyncGraphQLView
from .schema import schema
urlpatterns = [
path('graphql', AsyncGraphQLView.as_view(schema=schema)),
]
```
# Serving WSGI (sync)
Expose the strawberry API when using WSGI by setting your urls.py like this:
```python title="urls.py"
from django.urls import path
from strawberry.django.views import GraphQLView
from .schema import schema
urlpatterns = [
path('graphql', GraphQLView.as_view(schema=schema)),
]
```
|