Skip to content

Commit

Permalink
enterprise-1.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rmosolgo committed Oct 31, 2024
1 parent 4625e59 commit 152a30a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion guides/object_cache/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ This reduces latency for clients and reduces the load on your database and appli

## How

Before running a query, `ObjectCache` creates a fingerprint for the query using {{ "GraphQL::Query#fingerprint" | api_doc }} and {% internal_link "`Schema.context_fingerprint_for(ctx)`", "/object_cache/schema_setup#context-fingerprint" %}. Then, it checks the backend for a cached response which matches the fingerprint. If a match is found, the `ObjectCache` fetches the objects previously visited by this query and compares their current fingerprints to the ones in the cache. If the fingerprints all match, then the cached response returned.
Before running a query, `ObjectCache` creates a fingerprint for the query using {{ "GraphQL::Query#fingerprint" | api_doc }} and {% internal_link "`Schema.context_fingerprint_for(ctx)`", "/object_cache/schema_setup#context-fingerprint" %}. Then, it checks the backend for a cached response which matches the fingerprint.

If a match is found, the `ObjectCache` fetches the objects previously visited by this query. Then, it compares the current fingerprint of each object ot the one in the cache and checks `.authorized?` for that object. If the fingerprints all match and all objects pass authorization checks, then the cached response returned. (Authorization checks can be {% internal_link "disabled", "/object_cache/schema_setup#disabling-reauthorization" %}.)

If there is no cached response or if the fingerprints don't match, then the incoming query is re-evaluated. While it's executed, `ObjectCache` gathers the IDs and fingerprints of each object it encounters. When the query is done, the result and the new object fingerprints are written to the cache.

Expand Down
2 changes: 2 additions & 0 deletions guides/object_cache/runtime_considerations.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ pp result.context[:object_cache]
messages: ["...", "..."], # status messages about the cache's behavior
objects: Set(...), # application objects encountered during the query
uncacheable: true, # if ObjectCache found a reason that this query couldn't be cached (see `messages: ...` for reason)
reauthorized_cached_objects: true,
# if `.authorized?` was checked for cached objects, see "Disabling Reauthorization"
}
```

Expand Down
7 changes: 7 additions & 0 deletions guides/object_cache/schema_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,10 @@ end
```

By returning a new `MySchema.fingerprint`, _all_ previously-cached results will be expired.

## Disabling Reauthorization

By default, `ObjectCache` checks `.authorized?` on each object before returning a cached result. However, if all authorization-related considerations are present in the object's cache fingerprint, then you can disable this check in two ways:

- __per-query__, by passing `context: { reauthorize_cached_objects: false }`
- __globally__, by configuring `use GraphQL::Enterprise::ObjectCache, ... reauthorize_cached_objects: false`
1 change: 1 addition & 0 deletions guides/pro/checksums/graphql-enterprise-1.5.4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
77201981e1495aa32181b36ca444b020860f83e6a29d8a749beca11cb02d4ca8e25fdfad8dea1c0365b8616661d39452de72d861f0460828db03151a627fb7ee

0 comments on commit 152a30a

Please sign in to comment.