graphene/examples/flask_sqlalchemy/app.py

34 lines
558 B
Python
Raw Normal View History

2016-01-23 08:44:41 +03:00
from flask import Flask
from database import db_session, init_db
from schema import schema, Department
2016-01-23 22:00:00 +03:00
from graphql_flask import GraphQL
2016-01-23 08:44:41 +03:00
app = Flask(__name__)
2016-01-23 22:00:00 +03:00
app.debug = True
2016-01-23 08:44:41 +03:00
2016-01-23 22:00:00 +03:00
default_query = '''
{
node(id:"%s") {
name
employees {
edges {
node {
name
}
}
}
}
}'''.strip() % Department.global_id(1)
2016-01-23 08:44:41 +03:00
2016-01-23 22:00:00 +03:00
GraphQL(app, schema=schema, default_query=default_query)
2016-01-23 08:44:41 +03:00
@app.teardown_appcontext
def shutdown_session(exception=None):
db_session.remove()
if __name__ == '__main__':
init_db()
app.run()