• Stars
    star
    2,191
  • Rank 21,055 (Top 0.5 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created over 6 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python library for implementing GraphQL servers using schema-first approach.

Ariadne

Documentation Codecov


Ariadne

Ariadne is a Python library for implementing GraphQL servers.

  • Schema-first: Ariadne enables Python developers to use schema-first approach to the API implementation. This is the leading approach used by the GraphQL community and supported by dozens of frontend and backend developer tools, examples, and learning resources. Ariadne makes all of this immediately available to you and other members of your team.
  • Simple: Ariadne offers small, consistent and easy to memorize API that lets developers focus on business problems, not the boilerplate.
  • Open: Ariadne was designed to be modular and open for customization. If you are missing or unhappy with something, extend or easily swap with your own.

Documentation is available here.

Features

  • Simple, quick to learn and easy to memorize API.
  • Compatibility with GraphQL.js version 15.5.1.
  • Queries, mutations and input types.
  • Asynchronous resolvers and query execution.
  • Subscriptions.
  • Custom scalars, enums and schema directives.
  • Unions and interfaces.
  • File uploads.
  • Defining schema using SDL strings.
  • Loading schema from .graphql, .gql, and .graphqls files.
  • WSGI middleware for implementing GraphQL in existing sites.
  • Apollo Tracing and OpenTracing extensions for API monitoring.
  • Opt-in automatic resolvers mapping between camelCase and snake_case, and a @convert_kwargs_to_snake_case function decorator for converting camelCase kwargs to snake_case.
  • Built-in simple synchronous dev server for quick GraphQL experimentation and GraphQL Playground.
  • Support for Apollo GraphQL extension for Visual Studio Code.
  • GraphQL syntax validation via gql() helper function. Also provides colorization if Apollo GraphQL extension is installed.
  • No global state or object registry, support for multiple GraphQL APIs in same codebase with explicit type reuse.
  • Support for Apollo Federation.

Installation

Ariadne can be installed with pip:

pip install ariadne

Ariadne requires Python 3.7 or higher.

Quickstart

The following example creates an API defining Person type and single query field people returning a list of two persons. It also starts a local dev server with GraphQL Playground available on the http://127.0.0.1:8000 address.

Start by installing uvicorn, an ASGI server we will use to serve the API:

pip install uvicorn

Then create an example.py file for your example application:

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 {
        people: [Person!]!
    }

    type Person {
        firstName: String
        lastName: String
        age: Int
        fullName: String
    }
""")

# Map resolver functions to Query fields using QueryType
query = QueryType()

# Resolvers are simple python functions
@query.field("people")
def resolve_people(*_):
    return [
        {"firstName": "John", "lastName": "Doe", "age": 21},
        {"firstName": "Bob", "lastName": "Boberson", "age": 24},
    ]


# Map resolver functions to custom type fields using ObjectType
person = ObjectType("Person")

@person.field("fullName")
def resolve_person_fullname(person, *_):
    return "%s %s" % (person["firstName"], person["lastName"])

# Create executable GraphQL schema
schema = make_executable_schema(type_defs, query, person)

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

Finally run the server:

uvicorn example:app

For more guides and examples, please see the documentation.

Contributing

We are welcoming contributions to Ariadne! If you've found a bug or issue, feel free to use GitHub issues. If you have any questions or feedback, don't hesitate to catch us on GitHub discussions.

For guidance and instructions, please see CONTRIBUTING.md.

Website and the docs have their own GitHub repository: mirumee/ariadne-website

Also make sure you follow @AriadneGraphQL on Twitter for latest updates, news and random musings!

Crafted with ❤️ by Mirumee Software [email protected]

More Repositories

1

satchless

E-commerce for Python
Python
783
star
2

prices

Python price handling for humans.
Python
268
star
3

ariadne-codegen

Generate fully typed Python client for any GraphQL API from schema, queries and mutations
Python
265
star
4

django-prices

Django fields for the prices module
Python
158
star
5

google-i18n-address

Google's i18n address data packaged for Python.
Python
137
star
6

google-measurement-protocol

A Python implementation of Google Analytics Measurement Protocol
Python
103
star
7

ariadne-django

ariadne_django makes integrating ariadne and django together easier.
Python
64
star
8

django-images

A database-driven thumbnailing solution for Django
Python
63
star
9

django-messages

A Django application handling private messages between users.
Python
53
star
10

saleor-app-framework-python

Python Saleor App/Extension boilerplate. Batteries included.
Python
50
star
11

ariadne-graphql-modules

Ariadne package for implementing Ariadne GraphQL schemas using modular approach.
Python
36
star
12

chromedebug

A Chrome remote debugging protocol server for Python
Python
36
star
13

django-prices-openexchangerates

openexchangerates.org support for django-prices
Python
33
star
14

ariadne-website

The code that powers Ariadne website
JavaScript
24
star
15

serverless-saleor-app-example

Example implementation of Saleor app using AWS Lambda
Python
18
star
16

gql-federation-gateway

Simple gateway for Apollo Federation with JWT
JavaScript
18
star
17

django-offsite-storage

Cloud static and media file storage suitable for app containers
Python
17
star
18

django-prices-vatlayer

Vatlayer API support for django-prices
Python
15
star
19

bestest

Some of the bestest™ and cleverestest™ code out there
Python
14
star
20

django-voice

A simple user feedback application for your Django project
Python
14
star
21

ariadne-graphql-proxy

Ariadne toolkit for building GraphQL proxies.
Python
14
star
22

legacy-views

A legacy fork of Saleor that contains the old storefront and dashboard code
Python
14
star
23

graphql-workshop

A GraphQL workshop for DjangoCon EU 2019
Python
13
star
24

django-bootstrap-mockups

A template mocking tool for Django
Python
11
star
25

django-ariadne-deprecated

Django bindings for the Ariadne GraphQL library.
11
star
26

overv.io-beta

Private beta feedback
10
star
27

trapecssoid

CSS-based trapezoid blocks
CSS
10
star
28

saleor-demo

Saleor's demo setup
HTML
10
star
29

lynara

Python ASGI applications in an AWS Lambda runtime
Python
9
star
30

ariadne-lambda

Python
5
star
31

ariadne-graphql-chat-example

Simple Chat application using Ariadne and GraphQL Subscriptions
JavaScript
4
star
32

subgraph-template-ariadne-fastapi

Python
4
star
33

saleor-sdk-python

Python
4
star
34

smyth

A versatile tool that enhances your AWS Lambda development experience.
Python
4
star
35

opentracing-asgi

ASGI middleware reporting to the OpenTracing API
Python
3
star
36

saleor-product-mockups

Free Saleor product templates
3
star
37

codeclimate-isort

An isort plugin for codeclimate
Python
3
star
38

python-invoicible

Invoicible/CentrumFaktur library that provides pure Python interface to CentrumFaktur API
Python
2
star
39

saleor-graphql-deprecations

Deprecations tracker for Saleor's GraphQL API
Python
1
star
40

graphql-wroclaw-website

GraphQL Wrocław Meetup
JavaScript
1
star
41

overv.io-splash

Overv.io public webpage
HTML
1
star
42

js-invoicible

Invoicible/CentrumFaktur library that provides JavaScript interface to CentrumFaktur API
JavaScript
1
star
43

aws_secrets_cache

Cache AWS Secrets
Python
1
star
44

saleor-contentful-app

TypeScript
1
star
45

saleor-algolia-demo

Python
1
star