UNPKG

@profusion/apollo-federation-upload

Version:

This library makes it easier to support file uploads to your federated micro-services. It uses the [Apollo](https://www.apollographql.com/docs/apollo-server/data/file-uploads/) server's solution. It works by simply redirecting the file uploaded stream to

30 lines (29 loc) 947 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const form_data_1 = __importDefault(require("form-data")); class FormData extends form_data_1.default { /* This is a workaround to make node-fetch to work properly with unknown length streams, which was not released yet. https://github.com/node-fetch/node-fetch/pull/707 */ getLength(callback) { const cb = (err, length) => { if (err || !Number.isNaN(length)) { callback(err, length); } else { callback(null, null); } }; super.getLength(cb); } getLengthSync() { const len = super.getLengthSync(); return Number.isNaN(len) ? null : len; } } exports.default = FormData;