Strawberry-graphql: Difference between revisions
TobiasBora (talk | contribs) Created page with minimal example |
|||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
[https://strawberry.rocks/ Strawberry-graphql] is a is "a developer friendly ''GraphQL library'' [server] for Python, designed for modern development". | [https://strawberry.rocks/ Strawberry-graphql] is a is "a developer friendly ''GraphQL library'' [server] for Python, designed for modern development". | ||
=== Installation === | === Installation === | ||
To install it with all the packages needed for debugging purposes, you can start a nix shell like:<syntaxhighlight lang="bash"> | To install it with all the packages needed for debugging purposes, you can start a nix shell like:<syntaxhighlight lang="bash"> | ||
$ nix-shell -p "(python3.withPackages (ps: with ps; [ strawberry-graphql typer ] ++ strawberry-graphql.optional-dependencies.debug-server))" | $ nix-shell -p "(python3.withPackages (ps: with ps; [ strawberry-graphql typer ] ++ strawberry-graphql.optional-dependencies.debug-server ++ uvicorn.optional-dependencies.standard))" | ||
</syntaxhighlight>Then, you can create, as documented on strawberry's documentation, a minimal example like: | </syntaxhighlight>(if you do not need subscriptions, and therefore websockets, you can remove the <code>uvicorn.optional-dependencies</code>). | ||
Then, you can create, as documented on strawberry's documentation, a minimal example like: | |||
=== Minimal example === | === Minimal example === | ||
Line 32: | Line 33: | ||
$ curl -X POST -d '{"query": "query MyQuery { user { age name }}"}' -H 'Content-Type: application/json' "http://0.0.0.0:8000/graphql" | $ curl -X POST -d '{"query": "query MyQuery { user { age name }}"}' -H 'Content-Type: application/json' "http://0.0.0.0:8000/graphql" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Python]] |