Skip to content

Add strawberry as a Python library #962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/content/code/language-support/python/server/strawberry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Strawberry
description: Strawberry is a Python library for implementing code first GraphQL servers using modern Python features like type hints.
url: https://strawberry.rocks
github: strawberry-graphql/strawberry
---

Here's an example of a Strawberry hello world, first install the library:

```bash
pip install strawberry-graphql
```

Create an `app.py` file with this content:

```python
import strawberry

@strawberry.type
class Query:
@strawberry.field
def hello(self, name: str = "World") -> str:
return f"Hello {name}"

schema = strawberry.Schema(query=Query)
```

Then run `strawberry server app` and you will have a basic schema server
running on `http://localhost:8000/`.

Strawberry also has views for ASGI, Flask and Django and provides utilities
like dataloaders and tracing.