Skip to content
This repository was archived by the owner on Oct 26, 2022. It is now read-only.

Commit 4d544aa

Browse files
Add feature specs to cover caching connections
1 parent 880a4a0 commit 4d544aa

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

spec/features/connections_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require 'spec_helper'
2+
3+
def execute(query, context = {})
4+
CacheSchema.execute(query, context: context)
5+
end
6+
7+
RSpec.describe 'caching connection fields' do
8+
let(:query) do
9+
%Q{
10+
{
11+
customer(id: #{Customer.last.id}) {
12+
orders {
13+
edges {
14+
node {
15+
id
16+
}
17+
}
18+
}
19+
}
20+
}
21+
}
22+
end
23+
24+
it 'produces the same result on miss or hit' do
25+
cold_results = execute(query)
26+
warm_results = execute(query)
27+
28+
expect(cold_results).to eq warm_results
29+
end
30+
end

spec/spec_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
config.before(:suite) do
2626
GraphQL::Cache.cache = TestCache.new
2727
GraphQL::Cache.logger = TestLogger.new
28+
29+
DB.logger = GraphQL::Cache.logger
2830
end
2931

3032
# required after GraphQL::Cache initialization because dev

0 commit comments

Comments
 (0)