-
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.
Drop support for GraphQL version <= 1.7
- Loading branch information
Showing
4 changed files
with
28 additions
and
70 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,5 +10,4 @@ rvm: | |
env: | ||
- CI=true | ||
gemfile: | ||
- graphql-1.7.gemfile | ||
- graphql-latest.gemfile |
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 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,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 |