artsy / metaphysics

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

feat: add @cacheable directive (experiment) for use in Force CDN caching #6016

Closed mzikherman closed 1 month ago

mzikherman commented 1 month ago

We want to decorate queries with whether or not they can be cached, so we can opt-in queries for caching (despite a user being logged-in). This is very experimental/first-draft-y!

A GraphQL directive is a great generic way to...decorate(!), and would be extensible to other clients and doesn't require needing to override any Relay/query types (to add 'metadata') or anything esoteric like that.

Really, the only odd thing is that this decorator needs to be supported in the schema (so here in Metaphysics), but it's not actually for use in Metaphysics - it's more for use by Relay middleware to control caching headers when making the GraphQL request.

I guess it's not that odd, plus this doesn't actually do anything so we can easily remove it.