Connect to multiple data sources at once using Flask-GraphiQL
0
I'm building a GraphQL API that connects to two different databases. I'm trying to create a GraphQL interface using Flask-GraphQL but it appears I can only bind a single SQLAlchemy session to the app at once via the context variable: from flask import Flask from flask_graphql import GraphQLView from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker, scoped_session from schema import schema # connect to database sources engine1 = create_engine('sqlite:///db1.sqlite3') engine2 = create_engine('sqlite:///db2.sqlite3') session1 = scoped_session(sessionmaker(bind=engine1)) session2 = scoped_session(sessionmaker(bind=engine2)) # create app and add GraphiQL route app = Flask(__name__) app.add_url_rule('/graphql', view_func=GraphQLView.as_view( ...