Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Exceeding maxFieldSize generates unhelpful error message #159

Closed
sgehrman opened this issue Aug 2, 2019 · 2 comments
Closed

Exceeding maxFieldSize generates unhelpful error message #159

sgehrman opened this issue Aug 2, 2019 · 2 comments
Labels

Comments

@sgehrman
Copy link

sgehrman commented Aug 2, 2019

I've noticed that some jpgs I upload, I get this error:
BadRequestError: Invalid JSON in the ‘operations’ multipart field (https://github.com/jaydenseric/graphql-multipart-request-spec).

Some jpgs work fine, also noticed gifs give the same error.

@sgehrman
Copy link
Author

sgehrman commented Aug 3, 2019

After googling for a few hours, I figured it out. The docs aren't great.

const fileUploadOptions = {
    maxFieldSize: 1024 * 1024 * 10
};

const server = new ApolloServer({
    uploads: fileUploadOptions
});

@mike-marcacci
Copy link
Collaborator

@sgehrman - thanks for the report. Not sure how I missed this (my GitHub notifications have been having problems). This sounds like a bug in the sense that the error message is incorrect, even if the behavior (error if the field is too large) is correct.

@JacobT14 there are essentially 2 possibilities:

  1. The request is in fact invalid.
  2. You are hitting the max field size. It looks like we have a poor error message, but the actual behavior is correct. To eliminate this as a possibility, set maxFieldSize to Infinity.

@mike-marcacci mike-marcacci changed the title BadRequestError: Invalid JSON in the ‘operations’ multipart field Exceeding maxFieldSize generates unhelpful error message Oct 2, 2019
krasivyy3954 added a commit to krasivyy3954/react-graphql-upload that referenced this issue Jan 6, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants