graphene/examples/flask_sqlalchemy/app.py

35 lines
535 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
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 = '''
{
2016-01-24 00:14:10 +03:00
allEmployees {
edges {
node {
id
name
department {
2016-01-23 22:00:00 +03:00
name
}
}
}
}
2016-01-24 00:14:10 +03:00
}'''.strip()
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()