def create_app(path="/graphql", **kwargs): server = Flask(__name__) server.debug = True if kwargs.get("enable_async", None): server.add_url_rule(path, view_func=GraphQLView.as_view("graphql", schema=AsyncSchema, **kwargs)) else: server.add_url_rule(path, view_func=GraphQLView.as_view("graphql", schema=Schema, **kwargs)) return server
def create_app(path="/graphql", **kwargs): server = Flask(__name__) server.debug = True server.add_url_rule( path, view_func=GraphQLView.as_view("graphql", schema=Schema, **kwargs) ) return server
def create_graphql_view(): view = GraphQLView.as_view( 'graphql', schema=schema.graphql_schema, graphiql=True, get_context=get_context, ) return view
def create_app(path="/graphql", **kwargs): app = Flask("test_app") app.add_url_rule(path, view_func=GraphQLView.as_view( "graphql", schema=schema.graphql_schema, graphiql=True, **kwargs)) return app
import logging from graphql_server.flask import GraphQLView from api import schema from application import app from views.authentication import get_tokens, logout, steam_login from views.redirect import redirect_view from views.sitemap import sitemap_view from views.teams import teams_view logging.basicConfig(level=logging.INFO) try: app.add_url_rule("/graphql", view_func=GraphQLView.as_view( "graphql", schema=schema.graphql_schema, graphiql=True)) app.add_url_rule("/redirect/<provider>/<skin_id>/", view_func=redirect_view) app.add_url_rule("/sitemap.xml", view_func=sitemap_view, methods=["GET"]) app.add_url_rule("/teams.json", view_func=teams_view, methods=["GET"]) app.add_url_rule("/steam/login", view_func=steam_login) app.add_url_rule("/rest/jwt/", view_func=get_tokens, methods=["POST"]) app.add_url_rule("/rest/jwt/", view_func=logout, methods=["DELETE"]) except AssertionError: pass import commands # noqa
else: assert response.status == 200 assert "errors" not in body or not body["errors"] return response target_application["Sanic"] = sanic_execute # Flask flask_app = Flask("FlaskGraphQL") flask_middleware = [] flask_app.add_url_rule("/graphql", view_func=FlaskView.as_view( "graphql", schema=schema, middleware=flask_middleware)) flask_app = webtest.TestApp(flask_app) def flask_execute(query, middleware=None): if not isinstance(query, str) or "error" in query: expect_errors = True else: expect_errors = False set_middlware(middleware, flask_middleware) response = flask_app.post( "/graphql", json.dumps({"query": query}), headers={"Content-Type": "application/json"},