apollo-upload-client icon indicating copy to clipboard operation
apollo-upload-client copied to clipboard

Add `print` option to `createUploadLink`

Open pipopotamasu opened this issue 3 years ago • 8 comments

Fixed: https://github.com/jaydenseric/apollo-upload-client/issues/273, https://github.com/jaydenseric/apollo-upload-client/issues/275

pipopotamasu avatar Nov 11 '21 11:11 pipopotamasu

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 avatar Nov 13 '21 00:11 jaydenseric

@jaydenseric any word on this? I can't upgrade to apollo 3.5 because of this exact issue

tm1000 avatar Nov 23 '21 00:11 tm1000

@tm1000 status update here: https://github.com/jaydenseric/apollo-upload-client/issues/273#issuecomment-976035875 .

jaydenseric avatar Nov 23 '21 00:11 jaydenseric

@jaydenseric do you want to close this as well since Apollo fixed the underlying issue?

tm1000 avatar Nov 29 '21 21:11 tm1000

@tm1000 we can continue work in this PR to add support for the print option.

jaydenseric avatar Nov 29 '21 21:11 jaydenseric

@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?

pipopotamasu avatar Nov 30 '21 11:11 pipopotamasu

Any update on this or workarounds? We need the print option for this library.

nkramaric avatar Apr 14 '22 19:04 nkramaric

@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.

jaydenseric avatar Apr 15 '22 07:04 jaydenseric

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);

abumalick avatar Jun 07 '23 09:06 abumalick

v18 has been published, which includes the new option print for the function createUploadLink 🚀

jaydenseric avatar Oct 23 '23 13:10 jaydenseric