Skip to content

Instantly share code, notes, and snippets.

@rob-blackbourn
Created October 8, 2020 08:06
Show Gist options
  • Save rob-blackbourn/04442022218c290786ac64610e63af9e to your computer and use it in GitHub Desktop.
Save rob-blackbourn/04442022218c290786ac64610e63af9e to your computer and use it in GitHub Desktop.
Graphene 3 example ASGI application
import os
from typing import Any, Mapping
from bareasgi import Application
from bareasgi_cors import CORSMiddleware
from bareasgi_graphql_next.graphene import add_graphene
from baretypes import (
Scope,
Info,
Message
)
from jetblack_tweeter import Tweeter
from jetblack_tweeter.clients.bareclient import BareTweeterSession
from .schema import SCHEMA
def make_application() -> Application:
tweeter = Tweeter(
BareTweeterSession(),
os.environ["APP_KEY"],
os.environ["APP_KEY_SECRET"],
access_token=os.environ["ACCESS_TOKEN"],
access_token_secret=os.environ["ACCESS_TOKEN_SECRET"]
)
app = Application(
info=dict(tweeter=tweeter),
middlewares=[CORSMiddleware()]
)
add_graphene(
app,
SCHEMA
)
return app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment