Skip to content

Commit

Permalink
Drop support for GraphQL version <= 1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
exAspArk committed Feb 18, 2021
1 parent ddf8257 commit a2fcf1b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 70 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ rvm:
env:
- CI=true
gemfile:
- graphql-1.7.gemfile
- graphql-latest.gemfile
2 changes: 1 addition & 1 deletion batch-loader.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 2.0"
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "graphql", "~> 1.6"
spec.add_development_dependency "graphql", "~> 1.8"
spec.add_development_dependency "pry", "~> 0.14"
spec.add_development_dependency "benchmark-ips", "~> 2.7"
spec.add_development_dependency "ruby-prof", "~> 0.16"
Expand Down
7 changes: 0 additions & 7 deletions graphql-1.7.gemfile

This file was deleted.

88 changes: 27 additions & 61 deletions spec/fixtures/graphql_schema.rb
Original file line number Diff line number Diff line change
@@ -1,76 +1,42 @@
graphql_ruby_version = Gem::Version.new(GraphQL::VERSION)

if graphql_ruby_version < Gem::Version.new('1.8')
UserType = GraphQL::ObjectType.define do
name "User"
field :id, !types.ID
end
class UserType < GraphQL::Schema::Object
field :id, ID, null: false
end

PostType = GraphQL::ObjectType.define do
name "Post"
field :user, !UserType, resolve: ->(object, args, ctx) do
BatchLoader::GraphQL.for(object.user_id).batch do |user_ids, loader|
User.where(id: user_ids).each { |user| loader.call(user.id, user) }
end
end
class PostType < GraphQL::Schema::Object
field :user, UserType, null: false
field :user_old, UserType, null: false

field :userOld, !UserType, resolve: ->(object, args, ctx) do
BatchLoader.for(object.user_id).batch do |user_ids, loader|
User.where(id: user_ids).each { |user| loader.call(user.id, user) }
end
def user
BatchLoader::GraphQL.for(object.user_id).batch do |user_ids, loader|
User.where(id: user_ids).each { |user| loader.call(user.id, user) }
end
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
elsif
class UserType < GraphQL::Schema::Object
field :id, ID, null: false
end

class PostType < GraphQL::Schema::Object
field :user, UserType, null: false
field :user_old, UserType, null: false

def user
BatchLoader::GraphQL.for(object.user_id).batch do |user_ids, loader|
User.where(id: user_ids).each { |user| loader.call(user.id, user) }
end
end

def user_old
BatchLoader.for(object.user_id).batch do |user_ids, loader|
User.where(id: user_ids).each { |user| loader.call(user.id, user) }
end
def user_old
BatchLoader.for(object.user_id).batch do |user_ids, loader|
User.where(id: user_ids).each { |user| loader.call(user.id, user) }
end
end
end

class QueryType < GraphQL::Schema::Object
field :posts, [PostType], null: false
class QueryType < GraphQL::Schema::Object
field :posts, [PostType], null: false

def posts
Post.all
end
def posts
Post.all
end
end

class GraphqlSchema < GraphQL::Schema
class GraphqlSchema < GraphQL::Schema
query QueryType
use BatchLoader::GraphQL
end

if defined?(GraphQL::Execution::Interpreter)
class GraphqlSchemaWithInterpreter < GraphQL::Schema
use GraphQL::Execution::Interpreter
use GraphQL::Analysis::AST
query QueryType
use BatchLoader::GraphQL
end

if defined?(GraphQL::Execution::Interpreter)
class GraphqlSchemaWithInterpreter < GraphQL::Schema
use GraphQL::Execution::Interpreter
use GraphQL::Analysis::AST
query QueryType
use BatchLoader::GraphQL
end
end
end

0 comments on commit a2fcf1b

Please sign in to comment.