artsy / metaphysics

Artsy's GraphQL API
MIT License
360 stars 89 forks source link

feat: set Cache-control: no-cache when the query contains any errors #6006

Closed mzikherman closed 1 month ago

mzikherman commented 1 month ago

What this does

For more sane usage of our CDN - we've decided that we don't want to cache any GraphQL queries that contained errors. Our clients should likely be more resilient as they'll encounter such responses with errors, but if we cache those we'd likely be 'down' for longer than needed when there was some upstream hiccup.

Ideally, we'd be able to implement something that accomplishes this without needing to re-parse any response into JSON to look for errors, or anything like that.

To that end - I'm proposing a patch to express-graphql where we'll have access to the JSON.

Why a patch?

While we don't typically reach for patches, in this case: