apollo-upload-client
apollo-upload-client copied to clipboard
Add `print` option to `createUploadLink`
Fixed: https://github.com/jaydenseric/apollo-upload-client/issues/273, https://github.com/jaydenseric/apollo-upload-client/issues/275
Thanks for the issue and contribution! I'll try to review it sometime this week, and do a few maintenance chores too. At the moment I'm very focused on preparing a new package for release.
@jaydenseric any word on this? I can't upgrade to apollo 3.5 because of this exact issue
@tm1000 status update here: https://github.com/jaydenseric/apollo-upload-client/issues/273#issuecomment-976035875 .
@jaydenseric do you want to close this as well since Apollo fixed the underlying issue?
@tm1000 we can continue work in this PR to add support for the print option.
@jaydenseric I want to confirm a few things about this PR.
We have 2 ways to adopt print option in this PR, to use selectHttpOptionsAndBodyInternal or wait apollo-client updates untill selectHttpOptionsAndBody takes print option. I don't think to use selectHttpOptionsAndBodyInternal is good idea because this is not public function. So it is better to wait apollo-client updates untill selectHttpOptionsAndBody adopt print option.
What do you think about this topic?
Any update on this or workarounds? We need the print option for this library.
@nkramaric I don't know about workarounds, but I won't be working on this for probably several months. I have a lot more important open source things to work on first, for example https://github.com/jaydenseric/ruck/issues/1 . I also have maintenance to do for graphql-upload such as updating the busboy dependency that is a higher priority. After over a year working full time on open source for free now, I have to focus on paid work sometime soon and this apollo-upload-client stuff might have to come after contract work.
This patch package allowed us to use print in our app:
diff --git a/node_modules/apollo-upload-client/public/createUploadLink.js b/node_modules/apollo-upload-client/public/createUploadLink.js
index 9c396e9..2d1b311 100644
--- a/node_modules/apollo-upload-client/public/createUploadLink.js
+++ b/node_modules/apollo-upload-client/public/createUploadLink.js
@@ -4,9 +4,10 @@ const { ApolloLink, Observable } = require("@apollo/client/core");
const {
createSignalIfSupported,
fallbackHttpConfig,
+ defaultPrinter,
parseAndCheckHttpResponse,
rewriteURIForGET,
- selectHttpOptionsAndBody,
+ selectHttpOptionsAndBodyInternal,
selectURI,
serializeFetchParameter,
} = require("@apollo/client/link/http");
@@ -83,6 +84,7 @@ module.exports = function createUploadLink({
credentials,
headers,
includeExtensions,
+ print = defaultPrinter,
} = {}) {
const linkConfig = {
http: { includeExtensions },
@@ -113,11 +115,12 @@ module.exports = function createUploadLink({
},
};
- const { options, body } = selectHttpOptionsAndBody(
+ const { options, body } = selectHttpOptionsAndBodyInternal(
operation,
+ print,
fallbackHttpConfig,
linkConfig,
- contextConfig
+ contextConfig,
);
const { clone, files } = extractFiles(body, "", customIsExtractableFile);
v18 has been published, which includes the new option print for the function createUploadLink 🚀