from flask import Flask
from flask_cors import CORS
from flask_graphql import GraphQLView
from schema import Schema


def create_app(**kwargs):
    app = Flask(__name__)
    app.debug = True
    app.add_url_rule(
        '/graphql',
        view_func=GraphQLView.as_view('graphql', schema=Schema, **kwargs)
    )
    return app


if __name__ == '__main__':
    app = create_app(graphiql=True)
    CORS(app, resources={r'/graphql': {'origins': '*'}})
    app.run()

[((8, 10, 8, 25), 'flask.Flask', 'Flask', ({(8, 16, 8, 24): '__name__'}, {}), '(__name__)', False, 'from flask import Flask\n'), ((19, 4, 19, 56), 'flask_cors.CORS', 'CORS', (), '', False, 'from flask_cors import CORS\n'), ((12, 18, 12, 73), 'flask_graphql.GraphQLView.as_view', 'GraphQLView.as_view', (), '', False, 'from flask_graphql import GraphQLView\n')]