Returning a non-GraphQL response

I’m implementing a query that I want to be able to return either a standard GraphQL response or just the data in CSV format (and maybe other formats later). The desired format would be specified in the query. Is there any way to override the Apollo response pipeline to accomplish this? I realize I could return CSV-formatted data as a string in the GraphQL response, but I’d rather return a different content-type (text/csv) in this case) to allow the browser to directly handle that content type. I realize this is very non-standard, but I’m trying to avoid supporting a separate REST endpoint to do this.

What you’re asking for violates the GraphQL spec (must return a well-formed response), so I don’t think you’re going to find a GraphQL server library that supports your use case. My first reaction while reading your request was: “sounds like they want a separate endpoint”. It seems you’re already aware that’s a reasonable outcome even if it’s not quite what you want.