Return file from GraphQL resolveSaving binary data as file using JavaScript from a browserReadFile in Base64 NodejsHow do I check whether a file exists without exceptions?How do I copy a file in Python?How do I create a Java string from the contents of a file?Undo working copy modifications of one file in Git?How do I include a JavaScript file in another JavaScript file?Writing files in Node.jsHow to read a file line-by-line into a list?How do you append to a file in Python?What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?REST API router forward to Apollo GraphQL endpoinr

What do the positive and negative (+/-) transmit and receive pins mean on Ethernet cables?

categorizing a variable turns it from insignificant to significant

Pre-Employment Background Check With Consent For Future Checks

How can an organ that provides biological immortality be unable to regenerate?

"Marked down as someone wanting to sell shares." What does that mean?

Did I make a mistake by ccing email to boss to others?

Put the phone down / Put down the phone

Would this string work as string?

Hashing password to increase entropy

What 1968 Moog synthesizer was used in the Movie Apollo 11?

Friend wants my recommendation but I don't want to give it to him

Is there any common country to visit for persons holding UK and Schengen visas?

How can I, as DM, avoid the Conga Line of Death occurring when implementing some form of flanking rule?

How to preserve electronics (computers, ipads, phones) for hundreds of years?

How are passwords stolen from companies if they only store hashes?

How can a new country break out from a developed country without war?

How do you say "Trust your struggle." in French?

Is there a page on which I can view all Sitecore jobs running?

PTIJ: Which Dr. Seuss books should one obtain?

Can you take a "free object interaction" while incapacitated?

Connection Between Knot Theory and Number Theory

Why does the frost depth increase when the surface temperature warms up?

Why is implicit conversion not ambiguous for non-primitive types?

python displays `n` instead of breaking a line



Return file from GraphQL resolve


Saving binary data as file using JavaScript from a browserReadFile in Base64 NodejsHow do I check whether a file exists without exceptions?How do I copy a file in Python?How do I create a Java string from the contents of a file?Undo working copy modifications of one file in Git?How do I include a JavaScript file in another JavaScript file?Writing files in Node.jsHow to read a file line-by-line into a list?How do you append to a file in Python?What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?REST API router forward to Apollo GraphQL endpoinr













2















I am currently working on an application with the current tech stack:



Backend:



  • Mongoose


  • Express


  • Apollo


  • GraphQL


Frontend:



  • Vuejs


  • Apollo


  • GraphQL


I have succeeded in uploading files to the server using GraphQL, what I am stuck with is how to implement the 'download' feature. With a normal RESTApi endpoint I can use res.download(filePath) and it works. How do I do this with GraphQL since I don't want to use REST.



Or is there any other standard to go by in this scenario?



Thanks!










share|improve this question


























    2















    I am currently working on an application with the current tech stack:



    Backend:



    • Mongoose


    • Express


    • Apollo


    • GraphQL


    Frontend:



    • Vuejs


    • Apollo


    • GraphQL


    I have succeeded in uploading files to the server using GraphQL, what I am stuck with is how to implement the 'download' feature. With a normal RESTApi endpoint I can use res.download(filePath) and it works. How do I do this with GraphQL since I don't want to use REST.



    Or is there any other standard to go by in this scenario?



    Thanks!










    share|improve this question
























      2












      2








      2


      1






      I am currently working on an application with the current tech stack:



      Backend:



      • Mongoose


      • Express


      • Apollo


      • GraphQL


      Frontend:



      • Vuejs


      • Apollo


      • GraphQL


      I have succeeded in uploading files to the server using GraphQL, what I am stuck with is how to implement the 'download' feature. With a normal RESTApi endpoint I can use res.download(filePath) and it works. How do I do this with GraphQL since I don't want to use REST.



      Or is there any other standard to go by in this scenario?



      Thanks!










      share|improve this question














      I am currently working on an application with the current tech stack:



      Backend:



      • Mongoose


      • Express


      • Apollo


      • GraphQL


      Frontend:



      • Vuejs


      • Apollo


      • GraphQL


      I have succeeded in uploading files to the server using GraphQL, what I am stuck with is how to implement the 'download' feature. With a normal RESTApi endpoint I can use res.download(filePath) and it works. How do I do this with GraphQL since I don't want to use REST.



      Or is there any other standard to go by in this scenario?



      Thanks!







      node.js file express download graphql






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 4 at 12:16









      Edd ChangEdd Chang

      368




      368






















          1 Answer
          1






          active

          oldest

          votes


















          1














          GraphQL uses JSON format, which represents as text format, not as binary.



          If you don't want download files with REST, then you should:



          1. Encode your file content into base64 string on BE. Related question

          2. Send this string as part of query response.

          3. Save encoded base64 string as a file on FE. Related question

          But right architecture design is add a file link in the GraphQL response and use browser for downloading/rendering the file.






          share|improve this answer























          • thank you, this solves everything

            – Edd Chang
            Mar 7 at 10:30










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54983080%2freturn-file-from-graphql-resolve%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          GraphQL uses JSON format, which represents as text format, not as binary.



          If you don't want download files with REST, then you should:



          1. Encode your file content into base64 string on BE. Related question

          2. Send this string as part of query response.

          3. Save encoded base64 string as a file on FE. Related question

          But right architecture design is add a file link in the GraphQL response and use browser for downloading/rendering the file.






          share|improve this answer























          • thank you, this solves everything

            – Edd Chang
            Mar 7 at 10:30















          1














          GraphQL uses JSON format, which represents as text format, not as binary.



          If you don't want download files with REST, then you should:



          1. Encode your file content into base64 string on BE. Related question

          2. Send this string as part of query response.

          3. Save encoded base64 string as a file on FE. Related question

          But right architecture design is add a file link in the GraphQL response and use browser for downloading/rendering the file.






          share|improve this answer























          • thank you, this solves everything

            – Edd Chang
            Mar 7 at 10:30













          1












          1








          1







          GraphQL uses JSON format, which represents as text format, not as binary.



          If you don't want download files with REST, then you should:



          1. Encode your file content into base64 string on BE. Related question

          2. Send this string as part of query response.

          3. Save encoded base64 string as a file on FE. Related question

          But right architecture design is add a file link in the GraphQL response and use browser for downloading/rendering the file.






          share|improve this answer













          GraphQL uses JSON format, which represents as text format, not as binary.



          If you don't want download files with REST, then you should:



          1. Encode your file content into base64 string on BE. Related question

          2. Send this string as part of query response.

          3. Save encoded base64 string as a file on FE. Related question

          But right architecture design is add a file link in the GraphQL response and use browser for downloading/rendering the file.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 7 at 0:11









          galkingalkin

          2,57621537




          2,57621537












          • thank you, this solves everything

            – Edd Chang
            Mar 7 at 10:30

















          • thank you, this solves everything

            – Edd Chang
            Mar 7 at 10:30
















          thank you, this solves everything

          – Edd Chang
          Mar 7 at 10:30





          thank you, this solves everything

          – Edd Chang
          Mar 7 at 10:30



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54983080%2freturn-file-from-graphql-resolve%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

          Алба-Юлія

          Захаров Федір Захарович