Skip to content

Commit

Permalink
fix request creator to take an array of strings for the map rather th…
Browse files Browse the repository at this point in the history
…an just a string
  • Loading branch information
designatednerd committed Aug 13, 2019
1 parent 044e1a6 commit 18f9d2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Sources/Apollo/RequestCreator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public struct RequestCreator {
let operationData = try serializationFormat.serialize(value: fields)
formData.appendPart(data: operationData, name: "operations")

var map = [String: String]()
var map = [String: [String]]()
if files.count == 1 {
let firstFile = files.first!
map[firstFile.originalName] = "[variables.\(firstFile.fieldName)]"
map[firstFile.originalName] = ["variables.\(firstFile.fieldName)"]
} else {
for (index, file) in files.enumerated() {
map[file.originalName] = "[variables.\(file.fieldName).\(index)]"
map[file.originalName] = ["variables.\(file.fieldName).\(index)"]
}
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/ApolloTests/MultipartFormDataTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Content-Disposition: form-data; name="operations"
--TEST.BOUNDARY
Content-Disposition: form-data; name="map"
{"a.txt":"[variables.upload]"}
{"a.txt":["variables.upload"]}
--TEST.BOUNDARY
Content-Disposition: form-data; name="upload"; filename="a.txt"
Content-Type: text/plain
Expand All @@ -200,7 +200,7 @@ Alpha file content.
--TEST.BOUNDARY
Content-Disposition: form-data; name="map"
{"a.txt":"[variables.upload]"}
{"a.txt":["variables.upload"]}
--TEST.BOUNDARY
Content-Disposition: form-data; name="upload"; filename="a.txt"
Content-Type: text/plain
Expand Down Expand Up @@ -246,7 +246,7 @@ Content-Disposition: form-data; name="operations"
--TEST.BOUNDARY
Content-Disposition: form-data; name="map"
{"a.txt":"[variables.uploads.0]","b.txt":"[variables.uploads.1]"}
{"a.txt":["variables.uploads.0"],"b.txt":["variables.uploads.1"]}
--TEST.BOUNDARY
Content-Disposition: form-data; name="uploads"; filename="a.txt"
Content-Type: text/plain
Expand Down

0 comments on commit 18f9d2d

Please sign in to comment.