https://github.com/graphql-python/graphene
- Use example on the above Github page:
- Try Flask-GraphQL integration: https://github.com/graphql-python/flask-graphql
- Go through query examples https://docs.graphene-python.org/en/latest/quickstart/
- setup flask runner for starwars example
- play with custom ObjectType, Enums, Interfaces on GraphQL viewer
- Mutations:
- Adiadne: Schema-first GraphQL
- https://analytics.iotexscan.io/
- Deploy Flask project to production: https://flask.palletsprojects.com/en/1.1.x/tutorial/deploy/
- Chat App: https://nordicapis.com/create-a-chat-app-api-using-python-and-graphql/
The query below has a missing argument "todoId":
query {
todo {
success
errors
todo {
id
description
completed
dueDate
}
}
}
Since it is a bad request, the error thrown in production and debug mode is as follows:
{
"error": {
"errors": [
{
"locations": [
{
"column": 3,
"line": 13
}
],
"message": "Field 'todo' argument 'todoId' of type 'ID!' is required, but it was not provided.",
"path": null
}
]
}
}
The query below is an intended query to throw an exception:
query {
todoError(todoId: 1) {
success
errors
todo {
id
description
completed
dueDate
}
}
}
The error thrown in debug mode is as follows:
{
"data": null,
"errors": [
{
"extensions": {
"exception": {
"context": {
"info": "GraphQLResolv...7feb480e8820>)",
"obj": "None",
"todo_id": "'1'"
},
"stacktrace": [
"Traceback (most recent call last):",
" File \"/Users/wuhan/Documents/GitHub/graphql/graphql_server_python_101/venv/lib/python3.9/site-packages/graphql/execution/execute.py\", line 617, in resolve_field",
" result = resolve_fn(source, info, **args)",
" File \"/Users/wuhan/Documents/GitHub/graphql/graphql_server_python_101/venv/lib/python3.9/site-packages/ariadne/utils.py\", line 75, in wrapper",
" return func(*args, **convert_to_snake_case(kwargs))",
" File \"/Users/wuhan/Documents/GitHub/graphql/graphql_server_python_101/api/queries.py\", line 50, in resolve_todo",
" raise Exception('Intended error')",
"Exception: Intended error"
]
}
},
"locations": [
{
"column": 3,
"line": 2
}
],
"message": "Intended error",
"path": [
"todoError"
]
}
]
}
The error thrown in production mode is as follows. Compared to the one in debug mode, "extensions" field is missing:
{
"data": null,
"errors": [
{
"locations": [
{
"column": 3,
"line": 2
}
],
"message": "Intended error",
"path": [
"todoError"
]
}
]
}