Increasing body limit size in apollo-server-express
Asked Answered
S

1

7

I am trying to upload files to a webservice using the Upload scalar in apollo-server-express. I can upload small files(10s of kbs) to the webservice but am having trouble getting larger files to send.

I did some searching and found that I can change the body size limit using the body-parser package, along with the bodyParserConfig option set in middleware. I've tried implementing this, as well as implementing it in the express app itself, however neither seem to be working.

bodyParserConfig example snippet

const bodyParserConfig = bodyParser.urlencoded({limit: '50mb', extended: 'true', parameterLimit: 10000});


server.applyMiddleware({ app, path: process.env.GRAPHQL_ENDPOINT, bodyParserConfig});

I'm not sure if I need to use the json method as inside the apollo service it calls json(config) so I tried this and it also didnt work.

const bodyParserConfig = {limit: '50mb'};


server.applyMiddleware({ app, path: process.env.GRAPHQL_ENDPOINT, bodyParserConfig});

express example snippit

app.use(bodyParser.json({limit: '50mb'}))

Trying out both of these options, as well as options from Error: request entity too large don't seem to work for me. The webservice(Nifi HTTPHandleRequest) tells me it failed to receive content. Most examples of solutions(like the one above) have been specifically for express and not apollo-express-server so I'm not sure if theres a different approach I need to take. The apollo-server documents state to use the bodyParserConfig option, so I'm wondering if I'm not formatting the config correctly.

Is there something simple I'm doing incorrectly? Also how can I view what the limit is? It's hard to debug and see if the options I'm setting are actually doing anything.

Thanks

Snowflake answered 1/4, 2019 at 22:24 Comment(1)
Did you solve this problem? I'm facing the same problem!Omniumgatherum
G
0

I guess the first step in debugging is figuring out whether te faillure occurs on sending or receiving.

  1. Can you send this message to a different kind of webservice?
  2. Can you receive this message from a different tool into NiFi?

You don't mention how large the messages are, but it seems that in sending you try to set the limit to 50MB.

I don't think this is a problem for NiFi in general, but if you are specifically using multipart/form-data the default limit is set to 1MB.

This could be adjusted via the setting: Multipart Request Max Size

Generalization answered 12/4, 2021 at 12:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.