CSV response format for graphql read API
rufuspollock opened this issue · 3 comments
rufuspollock commented
When I have selected the data I want in the Build Report I want to be able to download in CSV format so that I can use it easily in my tools e.g. a spreadsheet, database etc
Acceptance
- I can make a query to build report API and indicate that I want results returned in CSV
- The results are returned in CSV
Tasks
- Design the API structure
- Add format query string to "graphql" endpoint with default to JSON
- Stream response instead of simple response.
- Implement CSV format option with conversion to CSV from JSON response
- Implement different separation formats TSV,
|
,;
, - Tests
- Implement different separation formats TSV,
Analysis
Current
/.../graphql
POST request
{ query MyQuery {
build_report_capacityauction {
MonthlyAuctionConRentDKK_DK1
UtilizedExportCapacity_DK1
}
}
}
New
POST with existing type of body to:
.../graphql?format=json|csv|xlsx
Options
New format:
Option 1:
POST /.../
Nicest:
.../graphql?format=json|csv|xlsx
Option 2:
{
"format": "json | csv | xlsx",
"graphql": "query MyQuery {
build_report_capacityauction {
MonthlyAuctionConRentDKK_DK1
UtilizedExportCapacity_DK1
}
}"
}
leomrocha commented
All formats supported by (js-xlsx)[https://github.com/SheetJS/sheetjs] will be easy to support with data-api after the current branch is tested and merged to the master.
For accepted formats read Library Documentation
rufuspollock commented
@leomrocha 👏 👏
Can we add a comment when closing as per https://playbook.datopian.com/issues-tasks/#closing-issues