Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce the way to clear cache manually, add GraphQL integration
- Loading branch information
Showing
14 changed files
with
242 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ sudo: false | |
language: ruby | ||
rvm: | ||
- 2.3.4 | ||
env: | ||
- CI=true | ||
before_install: gem install bundler -v 1.15.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe BatchLoader::Middleware do | ||
describe '#call' do | ||
it 'returns the result from the app' do | ||
app = ->(_env) { 1 } | ||
middleware = BatchLoader::Middleware.new(app) | ||
|
||
expect(middleware.call(nil)).to eq(1) | ||
end | ||
|
||
it 'clears the Executor' do | ||
app = ->(_) { nil } | ||
middleware = BatchLoader::Middleware.new(app) | ||
BatchLoader::Executor.ensure_current | ||
|
||
expect { | ||
middleware.call(nil) | ||
}.to change { | ||
BatchLoader::Executor.current | ||
}.to(nil) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
UserType = GraphQL::ObjectType.define do | ||
name "User" | ||
field :id, !types.ID | ||
end | ||
|
||
PostType = GraphQL::ObjectType.define do | ||
name "Post" | ||
field :user, !UserType, resolve: ->(post, args, ctx) { post.user_lazy } | ||
end | ||
|
||
QueryType = GraphQL::ObjectType.define do | ||
name "Query" | ||
field :posts, !types[PostType], resolve: ->(obj, args, ctx) { Post.all } | ||
end | ||
|
||
GraphqlSchema = GraphQL::Schema.define do | ||
query QueryType | ||
lazy_resolve BatchLoader, :sync | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.