Bunjil implements resolver level caching, by adhering to the same cacheControl
directives as apollo-cache-control. This give you the flexibility to use either Bunjil’s cache, just use Apollo Engine to cache, or both.
This is possible because the underlying GraphQL server implementation is apollo-server
, which comes with apollo-cache-control
.
Bunjil’s cache is in beta. It works, but it hasn’t had enough production use to understand any edge-cases. If you find one please file a ticket.
Schema Directives
@cacheControl
Argument | Type | Description |
---|---|---|
maxAge |
number |
Seconds until cache expiration. |
SCOPE |
string |
Either PUBLIC or PRIVATE . If PRIVATE the cache key is scoped to the logged in user. |
type Post @cacheControl(maxAge: 240) { |
Usage
When you create a new Bunjil
instance, pass true
at server.cacheControl
to enable the internal Bunjil cache.
import { Bunjil } from 'bunjil'; |
Caching Engine
Currently, Bunjil comes with an in-memory cache. The caching part of Bunjil has been written to easily be replaced with a binding to redis
or memcached
. These bindings are on the roadmap.