Skip to content

Commit

Permalink
Create GraphQL and GraphiQL views in Flask
Browse files Browse the repository at this point in the history
  • 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.
26 changes: 26 additions & 0 deletions app.py
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()

0 comments on commit 2b0098d

Please sign in to comment.