jaydenseric / graphql-upload

Middleware and a scalar Upload 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 132 forks source link

graphqlUploadKoa must be loaded after Apollo 2.0 applyMiddleware call? #192

Closed njg-nf closed 4 years ago

njg-nf commented 4 years ago

Otherwise graphql-upload tries to process all GraphQL requests for me. Posting issue as this is inconsistent with the documentation here:

Use the graphqlUploadKoa or graphqlUploadExpress middleware just before GraphQL middleware

mike-marcacci commented 4 years ago

This package will process all middleware that is sent with a Content-Type of multipart/form-data according to the GraphQL Multipart Request Spec but will not process those with another Content-Type, like application/json.

FWIW you're probably running into issues because Apollo itself uses this package to provide upload support, and so you're likely trying to process the multipart request twice.

The documented behavior is correct – this must be applied before any GraphQL-consuming middleware to have any effect.

njg-nf commented 4 years ago

FWIW you're probably running into issues because Apollo itself uses this package to provide upload support, and so you're likely trying to process the multipart request twice.

That does seem to have been the issue; I somehow was under the impression that this package was still necessary for file upload support when running Apollo.