Closed jamesaoverton closed 2 years ago
Sorry, my issue was not as clear as I thought. This issue is about Sprocket sitting between a user and a PostgREST endpoint and providing HTML views, not about bulk fetching from PostgREST. To implement this feature, Sprocket may need to store some schema information from the endpoint, but it should not be storing the actual data from the endpoint.
PostgREST is great. I love the core design of using accepting a query URL (and some optional HTTP headers) and returning table data. But there are two main features I want that it lacks:
Sprocket could be divided into two parts:
It would be inefficient for a user to configure Sprocket with a PostgREST backend (1.B) then request JSON or CSV format. We could support that use case by just redirecting (HTTP 301) from the Sprocket URL to the PostgREST URL.
OK, I will need to rework Sprocket to handle this. I wasn't able to find a schema that tells us all the columns in a table, though. Do you know if we can get this data anywhere?
I thought the Swagger JSON included all the columns but now I see that it does not. Sorry.
Another option is to query the table with limit 1 and no other parameters (especially no 'select' parameters). That would require an extra request. We could cache that information, but then we should also have a way to reset that cache.
It would be useful if we could point Sprocket at a PostgREST endpoint such as https://www.cmi-pb.org/api/v2 (Swagger here https://www.cmi-pb.org/docs/api/) and then explore the data with the HTML table.
I would like our query strings to match PostgREST (because I like their design), so ideally we could just pass the query string along to PostgREST, receive JSON or CSV from PostgREST, and then display it as HTML.
One problem I see is that a normal PostgREST like https://www.cmi-pb.org/api/v2/cell_type?select=cell_type_name will not return all the column names, which limits our HTML UI.
One option is for Sprocket to read the Swagger/OpenAPI description of the endpoint.