File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
src/content/code/language-support/python/server Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ name : Strawberry
3
+ description : Strawberry is a Python library for implementing code first GraphQL servers using modern Python features like type hints.
4
+ url : https://strawberry.rocks
5
+ github : strawberry-graphql/strawberry
6
+ ---
7
+
8
+ Here's an example of a Strawberry hello world, first install the library:
9
+
10
+ ``` bash
11
+ pip install strawberry-graphql
12
+ ```
13
+
14
+ Create an ` app.py ` file with this content:
15
+
16
+ ``` python
17
+ import strawberry
18
+
19
+ @strawberry.type
20
+ class Query :
21
+ @strawberry.field
22
+ def hello (self , name : str = " World" ) -> str :
23
+ return f " Hello { name} "
24
+
25
+ schema = strawberry.Schema(query = Query)
26
+ ```
27
+
28
+ Then run ` strawberry server app ` and you will have a basic schema server
29
+ running on ` http://localhost:8000/ ` .
30
+
31
+ Strawberry also has views for ASGI, Flask and Django and provides utilities
32
+ like dataloaders and tracing.
You can’t perform that action at this time.
0 commit comments