当前位置: 首页>>代码示例>>Python>>正文


Python GraphQLView.as_view方法代码示例

本文整理汇总了Python中flask_graphql.GraphQLView.as_view方法的典型用法代码示例。如果您正苦于以下问题:Python GraphQLView.as_view方法的具体用法?Python GraphQLView.as_view怎么用?Python GraphQLView.as_view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask_graphql.GraphQLView的用法示例。


在下文中一共展示了GraphQLView.as_view方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: after_init_app

# 需要导入模块: from flask_graphql import GraphQLView [as 别名]
# 或者: from flask_graphql.GraphQLView import as_view [as 别名]
def after_init_app(self, app: FlaskUnchained):
        if app.config.GRAPHENE_URL:
            app.add_url_rule(app.config.GRAPHENE_URL,
                             view_func=csrf.exempt(GraphQLView.as_view(
                                 'graphql',
                                 schema=self.root_schema,
                                 graphiql=app.config.GRAPHENE_ENABLE_GRAPHIQL,
                                 pretty=app.config.GRAPHENE_PRETTY_JSON,
                                 batch=False,
                             )),
                             methods=GraphQLView.methods,
                             strict_slashes=False)

        if app.config.GRAPHENE_BATCH_URL:
            app.add_url_rule(app.config.GRAPHENE_BATCH_URL,
                             view_func=csrf.exempt(GraphQLView.as_view(
                                 'graphql',
                                 schema=self.root_schema,
                                 graphiql=app.config.GRAPHENE_ENABLE_GRAPHIQL,
                                 pretty=app.config.GRAPHENE_PRETTY_JSON,
                                 batch=True,
                             )),
                             methods=GraphQLView.methods,
                             strict_slashes=False) 
开发者ID:briancappello,项目名称:flask-unchained,代码行数:26,代码来源:__init__.py

示例2: create_app

# 需要导入模块: from flask_graphql import GraphQLView [as 别名]
# 或者: from flask_graphql.GraphQLView import as_view [as 别名]
def create_app(sub_mgr, schema, options):
    app = Flask(__name__)
    sockets = Sockets(app)

    app.app_protocol = lambda environ_path_info: 'graphql-subscriptions'

    app.add_url_rule(
        '/graphql',
        view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))

    @app.route('/publish', methods=['POST'])
    def sub_mgr_publish():
        sub_mgr.publish(*request.get_json())
        return jsonify(request.get_json())

    @sockets.route('/socket')
    def socket_channel(websocket):
        subscription_server = SubscriptionServer(sub_mgr, websocket, **options)
        subscription_server.handle()
        return []

    return app 
开发者ID:hballard,项目名称:graphql-python-subscriptions,代码行数:24,代码来源:test_subscription_transport.py

示例3: __init__

# 需要导入模块: from flask_graphql import GraphQLView [as 别名]
# 或者: from flask_graphql.GraphQLView import as_view [as 别名]
def __init__(self, app):
        schema = graphene.Schema(query=Query, mutation=Mutation)

        app.add_url_rule(
            '/graphql',
            view_func=GraphQLView.as_view('graphql',
                                          schema=schema,
                                          graphiql=app.config['GRAPHIQL'])
        )

        schema_json = schema.introspect()

        @app.route("/schema")
        def schema_view():
            return jsonify(schema_json)

        print('[INFO] GraphQLView was successfully added with GraphiQL:{0}'.format(app.config['GRAPHIQL'])) 
开发者ID:NovemberOscar,项目名称:Flask-GraphQL-Large-Application-Example,代码行数:19,代码来源:__init__.py

示例4: graphql_token_view

# 需要导入模块: from flask_graphql import GraphQLView [as 别名]
# 或者: from flask_graphql.GraphQLView import as_view [as 别名]
def graphql_token_view():
    view = GraphQLView.as_view('graphql', schema=schema, graphiql=bool(app.config.get("DEBUG", False)))
    view = jwt_required()(view)
    return view 
开发者ID:yfilali,项目名称:graphql-pynamodb,代码行数:6,代码来源:schema.py

示例5: create_app

# 需要导入模块: from flask_graphql import GraphQLView [as 别名]
# 或者: from flask_graphql.GraphQLView import as_view [as 别名]
def create_app():
    app = Flask(__name__)
    app.add_url_rule('/graphql', view_func=GraphQLView.as_view(
        'graphql', schema=schema, graphiql=True)
    )

    @app.errorhandler(404)
    def page_not_found(e):
        return jsonify({'message': 'The requested URL was not found on the server.'}), 404

    return app 
开发者ID:elementsinteractive,项目名称:flask-graphql-neo4j,代码行数:13,代码来源:__init__.py

示例6: create_app

# 需要导入模块: from flask_graphql import GraphQLView [as 别名]
# 或者: from flask_graphql.GraphQLView import as_view [as 别名]
def create_app(path='/graphql', **kwargs):
    # backend = GraphQLCachedBackend(GraphQLQuiverBackend({"async_framework": "PROMISE"}))
    backend = None
    app = Flask(__name__)
    app.debug = True
    app.add_url_rule(path, view_func=GraphQLView.as_view('graphql', schema=Schema, backend=backend, **kwargs))
    return app 
开发者ID:graphql-python,项目名称:flask-graphql,代码行数:9,代码来源:app.py

示例7: create_app

# 需要导入模块: from flask_graphql import GraphQLView [as 别名]
# 或者: from flask_graphql.GraphQLView import as_view [as 别名]
def create_app():
    app = Flask(__name__)
    app.config.from_object((set_environment_config()))

    jwt = JWTManager(app)

    @jwt.expired_token_loader
    def my_expired_token_callback():
        return jsonify({
            'status': 401,
            'sub_status': 42,
            'msg': 'The token has expired'
        }), 401

    db.init_app(app)

    from app.models.User import User
    from app.models.VerificationCode import VerificationCode

    @app.before_first_request
    def initialize_database():
        db.create_all()

    @app.route('/')
    def hello_world():
        return "Hello World"

    from app.schema import schema

    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()

    return app 
开发者ID:MaxGoh,项目名称:Flask-GraphQL-Graphene-MySQL-Docker-StarterKit,代码行数:45,代码来源:__init__.py


注:本文中的flask_graphql.GraphQLView.as_view方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。