Closed ardatan closed 2 years ago
Some side notes about the actual implementation: It's great you guys are going for as few dependencies as possible; I'm not salty that you're not using graphql-upload
! But I do worry about the implications of such a simple approach, if my shallow understanding of it is correct.
Is it the first sync scenario explained in this graphic?
It appears you are awaiting the entire multipart request before running any resolvers:
If so, there are a few implications…
graphql-upload
to respond early before the request is finished, we currently choose not to because it can trigger browser bugs (see https://github.com/jaydenseric/graphql-upload/blob/0cbc9d90a181ace59be279fee4c3b269c47d1cbe/public/graphqlUploadKoa.js#L56).Also, not something problematic with the general strategy but an opportunity for improvement is error handling for when the GraphQL multipart request has weird/invalid form fields. In the early days before we had really robust checks in graphql-upload
for everything that could possible be wrong it was possible to bring down Apollo Server just with a maliciously structured request. Hopefully you are already testing for and handling such errors! You can see all the weird things we test for here:
https://github.com/jaydenseric/graphql-upload/blob/v13.0.0/test/public/processRequest.test.mjs
Aside from tightening security, it's nice to have meaningful error messages presented to the developer in the response if they get the structure of the GraphQL multipart request wrong. For example, somehow here would generate an error message if the operations
field is missing:
GraphQL Yoga implements GraphQL Multipart Spec in a different way by using WHATWG Fetch API. https://github.com/dotansimha/graphql-yoga/blob/master/packages/common/src/getGraphQLParameters.ts#L50