Giter Club home page Giter Club logo

tartiflette-asgi's Introduction

tartiflette-asgi logo

Build status Package version Code style

tartiflette-asgi is a wrapper that provides ASGI support for the Tartiflette Python GraphQL engine.

It is ideal for serving a GraphQL API over HTTP, or adding a GraphQL API endpoint to an existing ASGI application (e.g. FastAPI, Starlette, Quart, etc).

Full documentation is available at: https://tartiflette.github.io/tartiflette-asgi

Requirements

tartiflette-asgi is compatible with:

  • Python 3.6, 3.7 or 3.8.
  • Tartiflette 1.x.

Quickstart

First, install Tartiflette's external dependencies, as explained in the Tartiflette tutorial.

Then, you can install Tartiflette and tartiflette-asgi using pip:

pip install tartiflette "tartiflette-asgi==0.*"

You'll also need an ASGI web server. We'll use Uvicorn here:

pip install uvicorn

Create an application that exposes a TartifletteApp instance:

from tartiflette import Resolver
from tartiflette_asgi import TartifletteApp

@Resolver("Query.hello")
async def hello(parent, args, context, info):
    name = args["name"]
    return f"Hello, {name}!"

sdl = "type Query { hello(name: String): String }"
app = TartifletteApp(sdl=sdl, path="/graphql")

Save this file as graphql.py, then start the server:

uvicorn graphql:app

Make an HTTP request containing a GraphQL query:

curl http://localhost:8000/graphql -d '{ hello(name: "Chuck") }' -H "Content-Type: application/graphql"

You should get the following JSON response:

{ "data": { "hello": "Hello, Chuck!" } }

To learn more about using tartiflette-asgi, head to the documentation: https://tartiflette.github.io/tartiflette-asgi

Contributing

Want to contribute? Awesome! Be sure to read our Contributing guidelines.

Changelog

Changes to this project are recorded in the changelog.

License

MIT

tartiflette-asgi's People

Contributors

florimondmanca avatar dependabot-preview[bot] avatar autumnaldream avatar barrachri avatar saadismail avatar tsunammis avatar timgates42 avatar v-do avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.