UNPKG

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

18 lines (15 loc) 612 B
// @ts-check /** @import { ExtractableFile } from "./isExtractableFile.mjs" */ /** * The default implementation for the class `UploadHttpLink` constructor 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 {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); }