Skip to content

Add Ariadne to Python libraries list #950

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

Closed
wants to merge 2 commits into from
Closed
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
46 changes: 46 additions & 0 deletions src/content/code/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,52 @@ It also provides functionality for the construction of a WebSocket Subscriptions

### Python

#### [Ariadne](https://ariadnegraphql.org) ([github](https://github.com/mirumee/ariadne))

Ariadne is a Python library for implementing GraphQL servers using schema-first approach. It supports both synchronous and asynchronous query execution, ships with batteries included for common GraphQL server problems like query cost validation or performance tracing and has simple API that is easy to extend or replace.

Ariadne can be installed with pip:

```bash
pip install ariadne
```

It ships with many GraphQL server implementations, enabling easy experimentation:

```python
from ariadne import ObjectType, QueryType, gql, make_executable_schema
from ariadne.asgi import GraphQL

# Define types using Schema Definition Language (https://graphql.org/learn/schema/)
# Wrapping string in gql function provides validation and better error traceback
type_defs = gql("""
type Query {
hello: String!
}
""")

# Bind resolver functions to Query's fields using QueryType
query_type = QueryType()

# Resolvers are simple python functions
@query_type.field("hello")
def resolve_hello(*_):
return "Hello world!"

# Create executable GraphQL schema
schema = make_executable_schema(type_defs, query_type)

# Create an ASGI app using the schema, running in debug mode
app = GraphQL(schema, debug=True)
```

Above server can be ran with uvicorn:

```
pip install uvicorn
uvicorn example:app
```

#### [Graphene](http://graphene-python.org/) ([github](https://github.com/graphql-python/graphene))

A Python library for building GraphQL APIs.
Expand Down