-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create GraphQL and GraphiQL views in Flask
- Loading branch information
Pedro Guilherme Siqueira Moreira
committed
Aug 26, 2019
1 parent
91739f8
commit 2b0098d
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from flask import Flask | ||
from flask_graphql import GraphQLView | ||
|
||
from models import db_session | ||
from schema import schema | ||
|
||
app = Flask(__name__) | ||
app.debug = True | ||
|
||
app.add_url_rule( | ||
'/graphql', | ||
view_func=GraphQLView.as_view( | ||
'graphql', | ||
schema=schema, | ||
graphiql=True # for having the GraphiQL interface | ||
) | ||
) | ||
|
||
|
||
@app.teardown_appcontext | ||
def shutdown_session(exception=None): | ||
db_session.remove() | ||
|
||
|
||
if __name__ == '__main__': | ||
app.run() |