0

Graphql Mutations

class UploadMutation(graphene.Mutation):
    class Arguments:
        file = Upload(required=True)

    success = graphene.Boolean()

    def mutate(self, info, file, **kwargs):
        if not file.endswith('.xlsx'):
            raise GraphQLError('File formate should be "xlsx".')
        return UploadMutation(success=True)


class FileUploadMutation(graphene.ObjectType):
    upload_file = UploadMutation.Field()
  • I'm using below GraphQL mutations But I'm unable to upload files
mutation UploadFile{
  uploadFile(file: xxx){
    success
  }
}

Please Help me out

  • You have to pass file object to the request. This example could be helpful: https://github.com/lmcgartland/graphene-file-upload/blob/master/tests/test_flask.py – jorzel Jun 29 '22 at 08:12
  • Also https://stackoverflow.com/questions/49503756/how-can-i-upload-and-download-files-with-graphene-django or the many answers here https://stackoverflow.com/search?q=graphene+upload+file – Mark Chackerian Jul 13 '22 at 13:27

0 Answers0