-
Notifications
You must be signed in to change notification settings - Fork 730
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
Mo' Better Uploading #707
Mo' Better Uploading #707
Conversation
@kdvtrifork Would love an extra set of eyes on this from you if you've got some time today |
Sure thing! I can try to test with our system :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will test with our test server when I come tonight 🚀
Otherwise it look really good!
OK cool - I'll hold off on merging until you're able to test against your test server. Thank you for your help! |
I'do love to test it as well... Thanks a lot for your effort, Ellen! |
@Cleversou1983 I think if you point your Cocoapods/Carthage install at this branch you should be able to. Fair warning that #699, which has already been merged, might cause you an issue or two in setup. |
Testing against this branch, still not working for me, although the content-type has changed, here is my request, if it can help... ▿ http://madari-staging.herokuapp.com/graphql
I've still had to make and extension to my mutation input and set an typealias Upload = String From server site we get the error: Looks like the 'map' parameters is a string from server side... //// if let imageData = image.jpegData(compressionQuality: 0.7) {
} Maybe I'm doing something wrong? Thanks a lot Ellen |
@Cleversou1983 Nope, good catch - I flipped the order of the parens and the quotes, and it was incorrect. Give it a shot now! |
Ellen, I've tried again with no success, my request:
To make sure I get te last version, I've deintegrated pod from my project and run pod install again, and clear build folder... |
@Cleversou1983 What's the error you're getting now? |
@designatednerd Hi Ellen, sorry for delay, I'll get the log with my coworker tomorrow, thanks! |
3332805
to
18f9d2d
Compare
@kimdv @Cleversou1983 Any luck? |
@designatednerd My co-worker it's very busy and couldn't give me feedback about the log error, from the backend perspective, from the iOS perspective, look's like there's no changes, the 'map' doesn't show in the request (I think it should, right?)... Thanks! |
I'm currently looking into it. I'm looking into it with my backend developer |
@Cleversou1983 Yeah it should - can you share what the outgoing request looks like now? @kimdv oy. OK, ping me on Spectrum if there's anything I can help with |
@designatednerd Sure, after putting a breakpoint on line 267 of the HTTPNetwokTransport.swift file: (lldb) po request
The app gets stuck waiting for a response, which never happens... Thanks a lot! |
@Cleversou1983 can you try using something like |
@designatednerd Sure! It's nil... |
My co-worker send me the server log:
|
Hey, i know these logs are hard to understand so i will try to explain my understanding about the issue here: Looks like the |
@Rudiney Awesome, thanks - I think I might see what's happening here. I think in the How to do that is a bit more complex though... |
@Cleversou1983 Take a look at what I just pushed up and let me know if that works. Thank you and @Rudiney for your help! |
@designatednerd We're glad to help! Unfortunately still doesn't work... From the iOS side, here is the request (same as before): ▿ http://madari-staging.herokuapp.com/graphql
@Rudiney is a little busy right now, soon we post the server log here to see if can helps... Thanks again! |
@designatednerd The server log is the same as before... I'm using the 'add/upload-docs' branch. I've executed the 'pod reintegrate' and 'pod install' to make sure it get the fresh files... |
@Cleversou1983 is the callback not getting called because the call fails or is it just never getting called at all? |
@designatednerd That sounds good! I will try to make something, and then we can add an example for Absinthe. |
@designatednerd The upload succeeded from server side, but the completion closure never gets called at all (so I can't test for fail or success) and the app get stuck in my "busy" state... |
When the upload succeeds, are you able to see if the appropriate data is coming back from the server regardless of whether it's being processed properly? I'm trying to figure out if there's some kind of issue with how I've got this set up, or if your server is just not calling you back with anything once the upload succeeds. You should be able to check this by implementing the |
@designatednerd I'll implement the delegate to see if I get any result... Regard this: "When the upload succeeds, are you able to see if the appropriate data is coming back from the server regardless of whether it's being processed properly?" - No data at all! Thanks! |
OK I think you may need to chat with @Rudiney about why that's not getting you any data back then |
@designatednerd I've implemented the HTTPNetworkTransportTaskCompletedDelegate delegate, but still no response. My co-worker @Rudiney is on travel today and will not be able to access the server logs. But he told me that the request was OK and with 200 status... As soon as we can get any additional info, we'll post here... Thanks again! |
OK cool - I've just verified that what i've just pushed is now working with both single and multiple uploads from our local server that adheres to the spec, and that it's returning and parsing the correct info. Now let's see what our friend travis has to say. |
@designatednerd Well, the info we were able to get was the request I've made: {"operations"=>"{"operationName":"UploadFile","query":"mutation UploadFile($file: Upload!, $clientId: String!, $clientSecret: String!) { uploadFile(input: {file: $file, clientId: $clientId, clientSecret: $clientSecret}) { __typename attachment { __typename id } errors } }","variables":{"clientId":"xxxxx","clientSecret":"xxxxx","file":null}}", "map"=>"{"file":["variables.file"]}", "file"=>#<ActionDispatch::Http::UploadedFile:0x00005563d5e94b28 @tempfile=#Tempfile:/tmp/RackMultipart20190814-4-dgfkyy, @original_filename="file", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name="file"; filename="file"\r\nContent-Type: image/jpeg\r\n">, "operationName"=>"UploadFile", "query"=>"mutation UploadFile($file: Upload!, $clientId: String!, $clientSecret: String!) { uploadFile(input: {file: $file, clientId: $clientId, clientSecret: $clientSecret}) { __typename attachment { __typename id } errors } }", "variables"=>{"clientId"=>"xxxxx", "clientSecret"=>"xxxxx", "file"=>#<ActionDispatch::Http::UploadedFile:0x00005563d5e94b28 @tempfile=#Tempfile:/tmp/RackMultipart20190814-4-dgfkyy, @original_filename="file", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name="file"; filename="file"\r\nContent-Type: image/jpeg\r\n">}} And the server returned 200, from the server side, it worked well... I'got the last commit from this branch, but sill there's no response at all when the upload finishes... That's weird... Thanks a lot! |
@Cleversou1983 When you say |
…ernate type, it doesn't get hammered.
…it network transports conform.
guess we haven't been running these much...
2bbba88
to
fe0d847
Compare
I'm gonna go ahead and merge this - longer-term I'm gonna talk to my crew about trying to get the Star Wars sample app to also handle uploads so we can do some round-trip tests on that, but for now, I've validated this works against a server that matches the spec. |
@designatednerd Thanks a lot, Ellen... We'll try to make some tests soon... |
I started trying to get some real documentation together for uploading and noticed a few holes in the implementation. This PR tries to address what I found.
In this PR:
Content-Type
late enough that it was hammering the form data upload type which is set when there's form data.UploadingNetworkTransport
sub-protocol ofNetworkTransport
to capture that not all network transports handle uploads.HTTPNetworkTransport
andSplitNetworkTransport
conform to this protocol.upload
support to the mainApolloClient
class so you don't need a direct reference to the network transport anymore. Note that this will hit anassertionFailure
during development and return anError
in production if you attempt to use it with aNetworkTransport
which does not also conform toUploadingNetworkTransport
.RequestCreator
is properly creating multipart requests.