I wanna send a csv file in repose of graphql query. I am using Apollo server and Apollo client and Reactjs. (send a csv file from server to client)
can anybody give me an idea how can I implement it?
Yes, you can, but it's not built in and you have to override some things. It's more like a work around. Take these steps and you will get csv output: Add csv = graphene.
GraphQL requests can be sent via HTTP POST or HTTP GET requests. GET requests must be sent in the following format. The query, variables, and operation are sent as URL-encoded query parameters in the URL. In either request method (POST or GET), only query is required.
Note that the filename of the uploaded file must be the same as the link that you are generating it for, otherwise the upload link will not be valid. The data then gets returned to the GraphQL server which returns an upload link to the frontend.
the Graphql responses JSON format only if you like to download files in the front end you can implement another app like express to upload and download files from/to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With