Ariadne is a Python library for implementing GraphQL servers.
Project description
Ariadne
Ariadne is a Python library for implementing GraphQL servers, inspired by Apollo Server and built with GraphQL-core.
Currently the library already implements enough features to enable developers to build functional GraphQL APIs. It is also being dogfooded internally at number of projects.
Documentation is available here.
Installation
Ariadne can be installed with pip:
pip install ariadne
Quickstart
Following example creates API defining Person
type and single query field people
returning list of two persons. It also starts local dev server with GraphQL Playground available on the http://127.0.0.1:8888
address.
from ariadne import GraphQLMiddleware
# Define types using Schema Definition Language (https://graphql.org/learn/schema/)
type_defs = """
type Query {
people: [Person!]!
}
type Person {
firstName: String
lastName: String
age: Int
fullName: String
}
"""
# Resolvers are simple python functions
def resolve_people(*_):
return [
{"firstName": "John", "lastName": "Doe", "age": 21},
{"firstName": "Bob", "lastName": "Boberson", "age": 24},
]
def resolve_person_fullname(person, *_):
return "%s %s" % (person["firstName"], person["lastName"])
# Map resolver functions to type fields using dict
resolvers = {
"Query": {"people": resolve_people},
"Person": {"fullName": resolve_person_fullname},
}
# Create and run dev server that provides api browser
graphql_server = GraphQLMiddleware.make_simple_server(type_defs, resolvers)
graphql_server.serve_forever() # Visit http://127.0.0.1:8888 to see API browser!
For more guides and examples, please see the documentation.
Contributing
We are welcoming contributions to Ariadne! If you've found a bug, issue, got question or just want to drop general feedback, feel free to use GitHub issues.
For guidance and instructions, please see CONTRIBUTING.md
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ariadne-0.0.10.tar.gz
.
File metadata
- Download URL: ariadne-0.0.10.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5704d7b4d745ae67ec808d4e5409530ea62c54c696b9d379faf1c9f232c47bc4 |
|
MD5 | e243f0e58e88fe8eaf1db4ad82569e24 |
|
BLAKE2b-256 | a49df316a406ff5414ccb5292ef02bad121d31ec054c3021791f998e8880ef45 |
File details
Details for the file ariadne-0.0.10-py3-none-any.whl
.
File metadata
- Download URL: ariadne-0.0.10-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6785c7908f5fa0c0dcf368922415980124d6ff8a150e620c55698e731a16c75 |
|
MD5 | 0e0c36e22c7a9e7386970b499ea642ec |
|
BLAKE2b-256 | 804a8752678805470dcfb2f34dabbcaadac56f7768c9572924c090d81ecd6112 |