jaydenseric / graphql-upload

Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.
https://npm.im/graphql-upload
MIT License
1.43k stars 131 forks source link

Error: Unexpected token P in JSON at position 0 #299

Closed brahimouindali closed 2 years ago

brahimouindali commented 2 years ago

This is a simple demo for my case. https://codesandbox.io/s/reverent-hill-b4cohz?file=/pages/index.js it's very basic. so when I try to upload a file I get the response POST body missing, invalid Content-Type, or JSON object has no keys everything is working mutations and queries but the upload files not. graphql-upload could you please help me out because I can't figure it out, THANKS

jaydenseric commented 2 years ago

It appears you haven't setup the graphql-upload middleware, so the raw multipart request is hitting Apollo Server and it doesn't know how to process it. Please follow the graphql-upload installation instructions closely:

https://github.com/jaydenseric/graphql-upload#installation