Skip to content

Commit 18f9d2d

Browse files
fix request creator to take an array of strings for the map rather than just a string
1 parent 044e1a6 commit 18f9d2d

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Sources/Apollo/RequestCreator.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ public struct RequestCreator {
5555
let operationData = try serializationFormat.serialize(value: fields)
5656
formData.appendPart(data: operationData, name: "operations")
5757

58-
var map = [String: String]()
58+
var map = [String: [String]]()
5959
if files.count == 1 {
6060
let firstFile = files.first!
61-
map[firstFile.originalName] = "[variables.\(firstFile.fieldName)]"
61+
map[firstFile.originalName] = ["variables.\(firstFile.fieldName)"]
6262
} else {
6363
for (index, file) in files.enumerated() {
64-
map[file.originalName] = "[variables.\(file.fieldName).\(index)]"
64+
map[file.originalName] = ["variables.\(file.fieldName).\(index)"]
6565
}
6666
}
6767

Tests/ApolloTests/MultipartFormDataTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Content-Disposition: form-data; name="operations"
184184
--TEST.BOUNDARY
185185
Content-Disposition: form-data; name="map"
186186
187-
{"a.txt":"[variables.upload]"}
187+
{"a.txt":["variables.upload"]}
188188
--TEST.BOUNDARY
189189
Content-Disposition: form-data; name="upload"; filename="a.txt"
190190
Content-Type: text/plain
@@ -200,7 +200,7 @@ Alpha file content.
200200
--TEST.BOUNDARY
201201
Content-Disposition: form-data; name="map"
202202
203-
{"a.txt":"[variables.upload]"}
203+
{"a.txt":["variables.upload"]}
204204
--TEST.BOUNDARY
205205
Content-Disposition: form-data; name="upload"; filename="a.txt"
206206
Content-Type: text/plain
@@ -246,7 +246,7 @@ Content-Disposition: form-data; name="operations"
246246
--TEST.BOUNDARY
247247
Content-Disposition: form-data; name="map"
248248
249-
{"a.txt":"[variables.uploads.0]","b.txt":"[variables.uploads.1]"}
249+
{"a.txt":["variables.uploads.0"],"b.txt":["variables.uploads.1"]}
250250
--TEST.BOUNDARY
251251
Content-Disposition: form-data; name="uploads"; filename="a.txt"
252252
Content-Type: text/plain

0 commit comments

Comments
 (0)