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.42k stars 131 forks source link

Apollo Server v4 issue - BadRequestError: POST body missing, invalid Content-Type, or JSON object has no keys. #380

Closed AaronNGray closed 6 months ago

AaronNGray commented 6 months ago

I have updated both Apollo Server to v4 and Apollo Client to v3 and am getting an error on the server, the v3 client works with the old v3 server.

Test Example :- https://github.com/AaronNGray/apollo-v4-upload-test.git

BadRequestError: POST body missing, invalid Content-Type, or JSON object has no keys.
at new GraphQLErrorWithCode (file:///C:/Users/aaron/Test/apollo-v4-express-upload-test/api/node_modules/@apollo/server/dist/esm/internalErrorClasses.js:7:9)
at new BadRequestError (file:///C:/Users/aaron/Test/apollo-v4-express-upload-test/api/node_modules/@apollo/server/dist/esm/internalErrorClasses.js:75:9)
at runHttpQuery (file:///C:/Users/aaron/Test/apollo-v4-express-upload-test/api/node_modules/@apollo/server/dist/esm/runHttpQuery.js:75:23)
at runPotentiallyBatchedHttpQuery (file:///C:/Users/aaron/Test/apollo-v4-express-upload-test/api/node_modules/@apollo/server/dist/esm/httpBatching.js:34:22)
at ApolloServer.executeHTTPGraphQLRequest (file:///C:/Users/aaron/Test/apollo-v4-express-upload-test/api/node_modules/@apollo/server/dist/esm/ApolloServer.js:515:26)
AaronNGray commented 6 months ago

Really silly error, I was not including your middleware !

AaronNGray commented 6 months ago

Working example of Apollo Server v4 and Client v3 :-

https://github.com/AaronNGray/apollo-v4-express-upload-example