Hi,
Could not find any mention, whether apollo-server-lambda supports the GraphQL multipart request specification for uploading files as mutation arguments (like apollo-server does)
Hello @taikn apollo-server-lambda supports uploading files as mutation arguments like apollo-server does!
Hmmm, I am getting following error, when trying to upload a file using apollo-server-lambda, while uploading a file using apollo-server with same config, works without problems.
SyntaxError: Unexpected number in JSON at position 1
at JSON.parse (<anonymous>)
at graphqlHandler (/var/task/node_modules/apollo-server-lambda/dist/lambdaApollo.js:24:24)
at /var/task/node_modules/apollo-server-lambda/dist/ApolloServer.js:87:85
@taikn +1, getting the same error on simple graphql query execution:
I think that this error is due to apollo-server-lambda tries to parse event.body as JSON while apollo-upload-client sends uploading request with multipart/form-data content type
Here it is: https://github.com/apollographql/apollo-server/blob/master/packages/apollo-server-lambda/src/lambdaApollo.ts#L46
@unicodeveloper I guess it should parse such requests with something else to actually support uploading files?
any updates on this? having the same issue as well.
Having the same issue here. Any solutions?
...apollo-server-lambda supports uploading files as mutation arguments like apollo-server does!
@unicodeveloper - I don't believe that's true, going over the source code of apollo-server-lambda, there are no references to apollo-server-upload, compare that to the koa and express variants, which both explicitly call processRequest from apollo-upload-server as middleware that runs before the actual query is run. Could you explain how the file upload is supposed to work in apollo-server-lambda?
Seeing this error as well.
Im also getting this error using apollo-server-lambda
Anybody able to fix this?
I'd be keen for an update on this too. Or an alternative solution?
This looks like it could potentially be useful: https://github.com/myshenin/aws-lambda-multipart-parser#readme
+1
Same need here
This still is an issue, does anyone have any updates on this?
Any updates?
Thanks very much for reporting this! We think this is a great idea, and would definitely review a PR. If you (or anyone else) is interested in working on this, that would be great - thanks!
@jbaxleyiii Why was this issue closed? There is an open pull request here: https://github.com/apollographql/apollo-server/pull/1739
@jbaxleyiii Still waiting for the file upload to work in apollo-server-lambda ...
Any update ? I get the JSON.parse error.
Meanwhile I use another lambda without apollo to handle my file uploads :( but it makes me so sad ;(
This works! But there seems to be the limit of file size. I got this error when I tried to upload a large file like ~30M:
error: "Request Entity Too Large"
message: "Payload content length greater than maximum allowed: 10485760"
statusCode: 413
It's similar to this issue: https://github.com/apollographql/apollo-server/issues/3354
But in that case, it uses apollo-server-express. I cannot do the suggestion that @abernix provided:
serverApollo.applyMiddleware({
app,
route: {
payload: {
maxBytes: 52428800,
},
},
});
I also tried:
const options = {
uploadsConfig: {
maxFieldSize: 52428800, // bytes = 50MB
maxFileSize: 52428800,
maxFiles: 10
}
};
ApolloServer.createHandler(options);
But it does not take uploadsConfig. Any ideas?
Thanks!
This is not working. I got a new error in apollo server lambda but works fine in apollo server.
Exception -----------------------------------------------
[
[Error: Missing Content-Type] {
locations: undefined,
path: undefined,
extensions: { code: 'INTERNAL_SERVER_ERROR' }
}
]
@dcai-icfi it seems you are facing to a hard limit of AWS Lambda (Invocation payload | 6 MB) https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html#w603aac11c66c15
@Santhosh222 Did you resolve your solution?
Most helpful comment
Hmmm, I am getting following error, when trying to upload a file using
apollo-server-lambda, while uploading a file usingapollo-serverwith same config, works without problems.