@graphql-tools/links
Version:
A set of utils for faster development of GraphQL tools
29 lines (28 loc) • 1.33 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.createServerHttpLink = void 0;
const tslib_1 = require("tslib");
const apollo_upload_client_1 = require("apollo-upload-client");
const form_data_1 = tslib_1.__importDefault(require("form-data"));
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
const apolloImport = tslib_1.__importStar(require("@apollo/client"));
const AwaitVariablesLink_js_1 = require("./AwaitVariablesLink.js");
const apollo = apolloImport?.default ?? apolloImport;
const createServerHttpLink = (options) => apollo.concat(new AwaitVariablesLink_js_1.AwaitVariablesLink(), (0, apollo_upload_client_1.createUploadLink)({
...options,
fetch: node_fetch_1.default,
FormData: form_data_1.default,
isExtractableFile: (value) => (0, apollo_upload_client_1.isExtractableFile)(value) || value?.createReadStream,
formDataAppendFile: (form, index, file) => {
if (file.createReadStream != null) {
form.append(index, file.createReadStream(), {
filename: file.filename,
contentType: file.mimetype,
});
}
else {
(0, apollo_upload_client_1.formDataAppendFile)(form, index, file);
}
},
}));
exports.createServerHttpLink = createServerHttpLink;
;