-
I need to return the results of a graphql query as a csv instead of a json. I was thinking about having my frontend send the query to a REST endpoint, the function would run it through juniper, and respond with a CSV. Can the devs give input on a slicker way of pulling this off? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
There is nothing json-specific about juniper, so you can do whatever you want. The built integrations with http server frameworks use JSON, but there's no reason why you can't wrap them and use CSV for whatever logic you want. Or what its worth, The most idiomatic way is to have some sort of CSV field that you query via GraphQL and is encoded by a JSON. But again JSON isn't a requirement for GraphQL or juniper |
Beta Was this translation helpful? Give feedback.
@twiclo thus, there is no way to expose the inner
juniper::Value
fromGraphQLResponse
, the latest implementsserde::Serialize
. So, you either need aserde
-compatible CSV serializer, or, at least, serialize it into aserde_json::Value
(or similar) and then use it for your custom serialization, which won't differ much from serializaingjuniper::Value
directly.