Skip to content

Commit 11c1228

Browse files
author
Daniel Hartnell
committed
Fixes failing specs when query context is missing
1 parent b11d760 commit 11c1228

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/graphql/fragment_cache/fragment.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ def read_multi(fragments)
3030
FragmentCache.cache_store.read_multi(*cache_keys)
3131
end
3232

33-
fragments.map do |fragment|
34-
cache_lookup_event(
35-
cache_key: fragment.cache_key,
36-
operation_name: fragment.context.query.operation_name,
37-
path: fragment.path,
38-
cache_hit: cache_keys_to_values.key?(fragment.cache_key),
39-
)
33+
begin
34+
fragments.map do |fragment|
35+
cache_lookup_event(
36+
cache_key: fragment.cache_key,
37+
operation_name: fragment.context.query.operation_name,
38+
path: fragment.path,
39+
cache_hit: cache_keys_to_values.key?(fragment.cache_key),
40+
)
41+
end
42+
rescue
43+
# Allow cache_lookup_event to fail when we do not have the data we need
4044
end
4145

4246
# Fragmenst without values or with renew_cache: true in their context will have nil values like the read method

0 commit comments

Comments
 (0)