apollo-upload-client
Version:
A terminating Apollo Link for Apollo Client that fetches a GraphQL multipart request if the GraphQL variables contain files (by default FileList, File, or Blob instances), or else fetches a regular GraphQL POST or GET request (depending on the config and
17 lines (15 loc) • 577 B
JavaScript
// @ts-check
/**
* The default implementation for the function `createUploadLink` option
* `formDataAppendFile` that uses the standard {@linkcode FormData.append}
* method.
* @param {FormData} formData Form data to append the specified file to.
* @param {string} fieldName Field name for the file.
* @param {import("./isExtractableFile.mjs").ExtractableFile} file File to
* append.
*/
export default function formDataAppendFile(formData, fieldName, file) {
"name" in file
? formData.append(fieldName, file, file.name)
: formData.append(fieldName, file);
}