diff --git a/.changeset/healthy-hornets-guess.md b/.changeset/healthy-hornets-guess.md new file mode 100644 index 00000000..602a6c63 --- /dev/null +++ b/.changeset/healthy-hornets-guess.md @@ -0,0 +1,5 @@ +--- +'@apollo/sandbox': minor +--- + +adjust multipart form construction logic diff --git a/package-lock.json b/package-lock.json index b670060f..fcd15fa6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9987,7 +9987,7 @@ }, "packages/explorer": { "name": "@apollo/explorer", - "version": "3.6.0", + "version": "3.7.0", "license": "MIT", "dependencies": { "@types/whatwg-mimetype": "^3.0.0", @@ -10033,7 +10033,7 @@ }, "packages/sandbox": { "name": "@apollo/sandbox", - "version": "2.5.1", + "version": "2.7.0", "license": "MIT", "dependencies": { "@types/whatwg-mimetype": "^3.0.0", diff --git a/packages/sandbox/src/helpers/constructMultipartForm.ts b/packages/sandbox/src/helpers/constructMultipartForm.ts index f017b704..09b47dac 100644 --- a/packages/sandbox/src/helpers/constructMultipartForm.ts +++ b/packages/sandbox/src/helpers/constructMultipartForm.ts @@ -57,6 +57,7 @@ export const constructMultipartForm = async ({ let variablesWithNullsForFiles: | Record | undefined = requestBody.variables; + fileVariables.forEach( ({ files, variableKey, isMultiFile }, fileVariableIndex) => { if (files?.length) { @@ -68,9 +69,7 @@ export const constructMultipartForm = async ({ }; Array.from(files).forEach((file) => { map[i] = [ - `${ - fileVariables.length > 1 ? `${fileVariableIndex}.` : '' - }variables.${variableKey}${isMultiFile ? `.${i}` : ''}`, + `variables.${variableKey}${isMultiFile ? `.${fileVariableIndex}` : ''}`, ]; // in the request, there is expected to be a number appended that corresponds to each file // https://github.com/jaydenseric/graphql-multipart-request-spec#file-list