Python 是否可以返回带有google函数端点的graphql gui?

Python 是否可以返回带有google函数端点的graphql gui?,python,flask,graphql,graphene-python,Python,Flask,Graphql,Graphene Python,当我到达graphql gui的端点时,我想在Google函数中查看它。 通常我会使用这样的东西: app.add_url_rule( '/graphql', view_func=GraphQLView.as_view( 'graphql', schema=schema, graphiql=True, # for having the GraphiQL interface context=None ) )

当我到达graphql gui的端点时,我想在Google函数中查看它。 通常我会使用这样的东西:

app.add_url_rule(
    '/graphql',
    view_func=GraphQLView.as_view(
        'graphql',
        schema=schema,
        graphiql=True, # for having the GraphiQL interface
        context=None
    )
)
不确定这是否可行,但我想知道是否有人尝试过并取得了成功。

最终找到了答案。 这是一个有点愚蠢的想法,但它仍然有效! 您必须在正在部署的google函数中调用view函数。 这允许我托管一个无服务器的GraphQLAPI,非常简洁

def gql(request):
    # Response Headers
    responseHeaders = {
        'Content-Type': 'application/json',
        'Access-Control-Allow-Origin': '*',
        'Access-Control-Allow-Methods': 'POST, OPTIONS',
        'Access-Control-Allow-Headers': 'Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, Origin, X-Requested-With',
    }

    # Return Options
    if request.method == 'OPTIONS':
        return {
          'statusCode': 200,
          'headers': responseHeaders,
          'body': ''
        }

    # Check Authorization Request
    person_auth_response = check_person_auth(request)

    # Return Graphql View/Results
    graphql_view_instance = GraphQLView(schema=schema, graphiql=True, get_context=lambda: person_auth_response)
    return graphql_view_instance.dispatch_request()



if __name__ == '__main__':
    app = Flask(__name__)
    CORS(app)
    app.debug = True
    app.route('/gql', methods=['POST', 'OPTIONS'])(lambda: gql(request))
    app.run()