通过 Apollo Client 发送文件并在 Graphene Flask 服务器中接收
Send files via Apollo Client and receive in Graphene Flask server
我在我的 Flask 应用程序中使用 Graphene 包 (https://github.com/graphql-python/graphene) and graphene-file-upload (https://pypi.org/project/graphene-file-upload/)。我需要通过如下所示的突变接收文件:
class Picture(graphene.Mutation):
class Arguments:
file = Upload(required=True)
numerical_id = graphene.Int()
def mutate(self, info, file):
... continues
class Mutations(graphene.ObjectType):
picture = Picture.Field()
但是当我通过 Apollo 客户端 (https://www.apollographql.com/docs/react/) 发送突变时,我收到了这个错误:
Unknown type "Upload". Perhaps you meant "Float"?
Cannot query field "picture" on type "Mutations".
是否有任何解决方法?提前致谢!
您是否从 graphene_file_upload.scalars 导入上传?您还需要确保修复连接到 /graphql 视图的视图函数
我花了几个小时试图解决这个问题,因为突变通过 Postman 运行良好,但从前端发送时却不行。
问题是父组件使用的 ApolloProvider
与我预期的不同。
我在我的 Flask 应用程序中使用 Graphene 包 (https://github.com/graphql-python/graphene) and graphene-file-upload (https://pypi.org/project/graphene-file-upload/)。我需要通过如下所示的突变接收文件:
class Picture(graphene.Mutation):
class Arguments:
file = Upload(required=True)
numerical_id = graphene.Int()
def mutate(self, info, file):
... continues
class Mutations(graphene.ObjectType):
picture = Picture.Field()
但是当我通过 Apollo 客户端 (https://www.apollographql.com/docs/react/) 发送突变时,我收到了这个错误:
Unknown type "Upload". Perhaps you meant "Float"?
Cannot query field "picture" on type "Mutations".
是否有任何解决方法?提前致谢!
您是否从 graphene_file_upload.scalars 导入上传?您还需要确保修复连接到 /graphql 视图的视图函数
我花了几个小时试图解决这个问题,因为突变通过 Postman 运行良好,但从前端发送时却不行。
问题是父组件使用的 ApolloProvider
与我预期的不同。