2016-01-23 08:44:41 +03:00
|
|
|
from flask import Flask
|
|
|
|
|
2016-04-03 05:40:48 +03:00
|
|
|
from database import db_session, init_db
|
2016-01-28 23:32:09 +03:00
|
|
|
from flask_graphql import GraphQL
|
2016-04-03 05:40:48 +03:00
|
|
|
from schema import schema
|
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 {
|
2016-04-13 15:16:01 +03:00
|
|
|
id,
|
|
|
|
name,
|
2016-01-24 00:14:10 +03:00
|
|
|
department {
|
2016-04-13 15:16:01 +03:00
|
|
|
id,
|
|
|
|
name
|
|
|
|
},
|
|
|
|
role {
|
|
|
|
id,
|
2016-01-23 22:00:00 +03:00
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-13 15:16:01 +03:00
|
|
|
},
|
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()
|