-
-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support AWS Lambda #155
Comments
Since AWS will gather the whole request in memory before passing it on to your function, any workarounds to try to simulate a request stream for For propper AWS Lambda support we could publish a function that processes an event into something that can be passed into existing GraphQL handlers, without using I haven't thought a lot about the details, and don't plan to work on it personally anytime soon as I don't have a need for it for any of my work or personal projects. I prefer to process file uploads as the stream in, for a much faster response time: A function for Lambda should actually be a much simpler implementation that the current The GraphQL upload scalar promise in a serverless environment could resolve the same file upload details, except instead of |
I 100% agree that because the current implementation is so highly optimized for the case of streaming data, it would be a total disaster to try and use it for data that is already in memory. However, for the sake of maintaining the portability of users' resolvers, it might be best to retain the same API as this library (that with a promise which resolves metadata and a I think this would be fairly trivial to write, although like you I have neither need for this at the moment, nor the time to actually do it. |
Hi @samin I've recently forked this awesome package and added AWS Lambda support. I need someone to test it. https://www.npmjs.com/package/graphql-upload-minimal/v/1.1.0-0#aws-lambda TL;DR:
|
FYI after going down a rabbit hole with this, |
@vaunus , incidentally I was looking at it today. When you say
What do you mean? |
@federicobarera sorry I meant we're setting the Apollo handler up like this:
In Apollo v3 the above is all that is required for |
@vaunus gem! |
@vaunus by any chance did you use in conjunction with the serveless framework? If so, I've been hitting issues when working offline, as reported by multiple people here: dherault/serverless-offline#464 |
@federicobarera no, we are not using the I instead went with AWS SAM for the deployment side, and for local dev implemented our own custom server which is a basic Express server that maps This is effectively replicating what a real lambda does with a binary body arriving encoded as base64. |
It seems to be working fine for me with serverless-offline (8.1.0). What errors do you get? |
@deniapps The issue, as pointed out by vaunus, is with the body of the request arriving with the wrong format / encoding. I am running serverless-offline |
You're right. The file is corrupted that I did not notice. |
Any workaround for this? I was trying to move my NestJS GraphQL project that supports file upload to AWS lambda. While debugging the file upload errors I came across this weird behavior: On the ec2 instance the file input that I receive in the mutation argument is of format:
In this case file upload works fine. But on lambda function, the same file input in the mutation argument is of form
It seems like the Upload scalar is not working properly in the lambda function Package versions
|
@piyushk96 I forked this module and made it work in Lambdas: https://github.com/flash-oss/graphql-upload-minimal#aws-lambda const { processRequest } = require("graphql-upload-minimal");
module.exports.processRequest = function (event) {
return processRequest(event, null, { environment: "lambda" });
}; |
@koresar I'm unable to use your package as it has peer dependency of Graphql v.13.1 - 15 and I'm using Graphql v16. So, npm is throwing an error when I try to install your package |
Oh. Sorry about that.
I can easily fix that on Monday. Or, perhaps, you can submit a PR fixing
that. I'll publish immediately.
…On Sat, 9 Apr 2022, 02:50 Piyush Kakkar, ***@***.***> wrote:
@koresar <https://github.com/koresar> I'm unable to use your package as
it has peer dependency of Graphql v.13.1 - 15 and I'm using Graphql v16.
So, npm throwing an error when I try to install your package
—
Reply to this email directly, view it on GitHub
<#155 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMMEL6UPZTROD7SQHKJ74LVEBPU5ANCNFSM4HZMSQHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I've got you sorted @piyushk96 |
Thanks @koresar for the update. But the original |
It's hard to use the actual
processRequest
for Lambda because it does not give me arequest
,response
model to follow to write a middleware. I've rewritten it to accept anevent
given inexports.handler = async (event, context) => {}
https://gist.github.com/samin/976271f97b03bba14017a760570df88a
Would it be possible to add it?
The text was updated successfully, but these errors were encountered: