@cache

πŸ“£ Note: This functionality will be available soon.

The @cache directive stores the result from a field in disk for a requested amount of time. When executing the same field within that time span, the cached value is returned.

This directive is useful to avoid the execution of expensive operations, such as when interacting with external APIs.

In this example, a call to Google Translate is cached for 10 seconds. Execute the query twice within this time span, to observe the difference in field resolution time. A log entry will indicate if the field is being retrieved from the cache: