-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
96 additions
and
23 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 |
---|---|---|
|
@@ -10,3 +10,4 @@ | |
|
||
# rspec failure tracking | ||
.rspec_status | ||
.ruby-version |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,7 +1,23 @@ | ||
sudo: false | ||
language: ruby | ||
rvm: | ||
- 2.3.4 | ||
env: | ||
- CI=true | ||
before_install: gem install bundler -v 1.15.3 | ||
before_install: gem install bundler -v 1.17.1 | ||
matrix: | ||
include: | ||
- gemfile: graphql-1.7.gemfile | ||
env: GRAPHQL_RUBY_VERSION=1_7 CI=true | ||
rvm: 2.3.8 | ||
- gemfile: graphql-1.8.gemfile | ||
env: GRAPHQL_RUBY_VERSION=1_8 CI=true | ||
rvm: 2.3.8 | ||
- gemfile: graphql-1.7.gemfile | ||
env: GRAPHQL_RUBY_VERSION=1_7 CI=true | ||
rvm: 2.4.5 | ||
- gemfile: graphql-1.8.gemfile | ||
env: GRAPHQL_RUBY_VERSION=1_8 CI=true | ||
rvm: 2.4.5 | ||
- gemfile: graphql-1.7.gemfile | ||
env: GRAPHQL_RUBY_VERSION=1_7 CI=true | ||
rvm: 2.5.3 | ||
- gemfile: graphql-1.8.gemfile | ||
env: GRAPHQL_RUBY_VERSION=1_8 CI=true | ||
rvm: 2.5.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source "https://rubygems.org" | ||
|
||
gem 'coveralls' | ||
|
||
gem "graphql", "~> 1.7" | ||
|
||
gemspec |
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,7 @@ | ||
source "https://rubygems.org" | ||
|
||
gem 'coveralls' | ||
|
||
gem "graphql", "~> 1.8" | ||
|
||
gemspec |
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 |
---|---|---|
@@ -1,19 +1,59 @@ | ||
UserType = GraphQL::ObjectType.define do | ||
name "User" | ||
field :id, !types.ID | ||
end | ||
case ENV['GRAPHQL_RUBY_VERSION'] | ||
when '1_7' | ||
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 | ||
PostType = GraphQL::ObjectType.define do | ||
name "Post" | ||
field :user, !UserType, resolve: ->(object, args, ctx) { object.user_lazy } | ||
field :userId, !types.Int, resolve: ->(object, args, ctx) do | ||
BatchLoader.for(object).batch do |posts, loader| | ||
posts.each { |p| loader.call(p, p.user_lazy.id) } | ||
end | ||
end | ||
end | ||
|
||
QueryType = GraphQL::ObjectType.define do | ||
name "Query" | ||
field :posts, !types[PostType], resolve: ->(obj, args, ctx) { Post.all } | ||
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 | ||
use BatchLoader::GraphQL | ||
end | ||
when '1_8' | ||
class UserType < GraphQL::Schema::Object | ||
field :id, ID, null: false | ||
end | ||
|
||
class PostType < GraphQL::Schema::Object | ||
field :user, UserType, null: false | ||
field :user_id, Int, null: false | ||
|
||
def user | ||
object.user_lazy | ||
end | ||
|
||
def user_id | ||
BatchLoader.for(object).batch do |posts, loader| | ||
posts.each { |p| loader.call(p, p.user_lazy.id) } | ||
end | ||
end | ||
end | ||
|
||
class QueryType < GraphQL::Schema::Object | ||
field :posts, [PostType], null: false | ||
|
||
def posts | ||
Post.all | ||
end | ||
end | ||
|
||
GraphqlSchema = GraphQL::Schema.define do | ||
query QueryType | ||
use BatchLoader::GraphQL | ||
class GraphqlSchema < GraphQL::Schema | ||
query QueryType | ||
use BatchLoader::GraphQL | ||
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
require "bundler/setup" | ||
|
||
ENV['GRAPHQL_RUBY_VERSION'] ||= '1_8' | ||
|
||
if ENV['CI'] | ||
require 'coveralls' | ||
Coveralls.wear! | ||
|