hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
31.17k stars 2.77k forks source link

Provide 404 response on RESTified endpoints if response is empty #10184

Open typhonius opened 7 months ago

typhonius commented 7 months ago

Is your proposal related to a problem?

RESTified endpoints currently return 200 for every response in a manner congruent with the GraphQL specification rather than following REST rules which would preordain a 4xx response

Describe the solution you'd like

When an empty response is returned from Hasura via a RESTified endpoint, I would like it to return 404

This could be placed behind a feature flag or environment variable or made user configurable. This will help data access requests via Hasura and REST to align to expectations of API consumers

bureku commented 7 months ago

A general rule of "empty response" == 404 might not be accurate to meet the expectation of REST specifications. e.g. if it's a search endpoint POST /search, a 200 response with an empty body or array is fine. However, if the endpoint explicitly ask for a specific resource GET /customers/{id}, then it is expected to return 404 if that resource is not found.