Created
October 8, 2020 08:06
-
-
Save rob-blackbourn/04442022218c290786ac64610e63af9e to your computer and use it in GitHub Desktop.
Graphene 3 example ASGI application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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