Store json response as file (in s3 bucket)

my graphql response payload is a very huge json object(1-80MB). So Instead of returning the json as response I am planning to store it in file. I m doing this in formatResponse of ApolloServer.

For small size file it is working but for big file it don’t. I am assuming this is because s3.upload is time taking process but fomatResponse finishes before uploading.

also formatResponse does not support async wait. so I cannot make code to wait the upload to finish.
I m not sure what is the best place to perform s3 upload to save my response as file.

Can you describe what kind of data we’re talking about that would be 80MB?

As in, why would it go from 1-80MB?