-
-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing multipart field 'operations' #164
Comments
You definitely don't want the I don't know much about Firebase, but if you check the issues here you will see that some cloud environments (particularly serverless ones) don't support standard multipart requests, or they do, but they do all the parsing for you and pass the result on from memory. |
As @jaydenseric mentioned, you definitely can't use I think it's safe to say that you can close your other issue at least as it relates to its use in conjunction with this library. I also see that you're running this in Google Cloud Functions. The HTTP emulator for cloud functions deviates from node's standards in some important ways. You can make this work, but it's not optimized for that use case. If you know that you'll just be dealing with small files, this isn't a serious concern. However, if you expect large files or serious traffic, you may want to start an API-compatible version of this package that plays more nicely with Google Could Functions. I may be missing something about your use case, so I'll leave this open for now, but I suspect that this can be closed in favor of #129. |
@mike-marcacci thanks for these details! To do #129 I will have to fork and link the NPM to test the implementation. I'm only sending images and eventually videos. I was thinking to avoid using graphql to upload, go directly to my storage containers. What are the pros vs cons with these two options? Thanks! |
@adriaanbalt if you are set on using cloud functions for your API, that may be a good workaround. They really aren't designed to do any sort of heavy lifting, and they have hard timeouts that will make uploads of large videos impossible. IIRC Google Cloud Storage has pre-signed URLs, so it may be possible to:
From an API simplicity perspective this is not ideal, but from an implementation perspective it may do the trick. I'm going to go ahead and close this issue, as I don't think it's a bug here :) |
Thanks @mike-marcacci Just so you have a sense of what I'm trying to create: I'm using cloud functions to "host" the GraphQL API like this Originally I was going to setup my app like this:
Then I came across So it looks like I'm back to my original approach. Unless you can suggest an alternative? Thanks for all your help and guidance; loving and learning so much when using these utils! |
@adriaanbalt, yes graphql-upload would be a very elegant solution, but isn't a great fit for cloud functions. (Large file uploads in general aren't a great fit for cloud functions...) I think what you are describing is a perfectly fine strategy, especially if you're in control of both the server and client. I will mention, though, that you will want to be able to control who has access to upload files to prevent potentially costly abuse of your systems (hence my reference to pre-signed URLs). |
@adriaanbalt I have been headed down the exact same path as you with Firebase Functions. I have all of my file uploads working on local nodejs server, but when I run via the cloud functions I too am seeing the Bad Request Error. Before I keep digging and investigating my own potential solution and reverting back to interfacing directly with Firebase Storage, I wanted to get your thoughts on where you ended up landing with GraphQL FileUploads via firebase functions... |
For folks that encountered this issue, if you have middlewares like |
I solve it, by adding |
@Enmanuellperez98 +1 to this solution, was the fix for me as well. Not sure the root cause of the error, but I'll take it 😄 |
Hey @namadaza, It seems that in previous versions of Apollo Server, they had a built-in integration with an old version of Take a look at this implementation of the repo author: new ApolloServer ({
// Disable the built in file upload implementation that uses an outdated
// `graphql-upload` version, see:
// https://github.com/apollographql/apollo-server/issues/3508#issuecomment-662371289
uploads: false,
schema,
}). applyMiddleware ({app}); |
Hi, a have this code in NestJS app module GraphQLModule.forRoot({
autoSchemaFile: true,
sortSchema: true,
uploads: false,
}), but I also get "Missing multipart field 'operations'". Anybody knows how to figure this out? |
This can happen when using apollo server express to host a graphql and a rest api. The failing request was multipart. So to fix it, I changed it to application/x-www-form-urlencoded from the frontend. Hope this helps someone. |
Had the same issue with |
did you manage to solve the problem? |
Guys any help here, i am getting the same error |
Firstly, thanks for all this great work; I appreciate it.
I've been trying to send files with GraphQL over Firebase HTTP Cloud Functions and upload them to Firebase Storage as well as update Firebase Firestore DB; ideally using a Firebase Transaction. For some reason I keep getting the following error:
BadRequestError: Missing multipart field ‘operations’ (https://github.com/jaydenseric/graphql-multipart-request-spec).
I've tried a bunch of things using Busboy, Rawbody and Express-Multipart-File-Parser; you can see a conversation I've been having with snippets of my code in this "issue" here. Note: code snippets are also copied at the bottom
Even with the above setup (using
uploads
property when using ApolloServer, etc) I am still getting theBadRequestError
. My headers look like this:And here is a curl:
It appears that I am sending
operations
in Form Data. What am I missing with my server setup?Server:
React Front End:
The text was updated successfully, but these errors were encountered: