souls 0.22.8 → 0.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/exe/souls +60 -48
- data/lib/souls.rb +5 -1
- data/lib/souls/generate/connection.rb +1 -1
- data/lib/souls/generate/edge.rb +1 -1
- data/lib/souls/generate/model.rb +1 -1
- data/lib/souls/generate/mutation.rb +1 -1
- data/lib/souls/generate/policy.rb +1 -1
- data/lib/souls/generate/query.rb +2 -2
- data/lib/souls/generate/resolver.rb +1 -1
- data/lib/souls/generate/rspec_factory.rb +1 -1
- data/lib/souls/generate/rspec_model.rb +1 -1
- data/lib/souls/generate/rspec_mutation.rb +1 -1
- data/lib/souls/generate/rspec_policy.rb +1 -1
- data/lib/souls/generate/rspec_query.rb +1 -1
- data/lib/souls/generate/rspec_resolver.rb +1 -1
- data/lib/souls/generate/type.rb +1 -1
- data/lib/souls/init.rb +1 -1
- data/lib/souls/version.rb +1 -1
- data/souls.gemspec +1 -1
- metadata +3 -117
- data/hoy/.env.sample +0 -7
- data/hoy/.gitignore +0 -32
- data/hoy/.irbrc +0 -1
- data/hoy/.rspec +0 -3
- data/hoy/.rubocop.yml +0 -132
- data/hoy/.ruby-version +0 -1
- data/hoy/CODE_OF_CONDUCT.md +0 -74
- data/hoy/Dockerfile +0 -16
- data/hoy/Dockerfile.dev +0 -17
- data/hoy/Gemfile +0 -50
- data/hoy/Gemfile.lock +0 -407
- data/hoy/LICENSE.txt +0 -67
- data/hoy/Procfile +0 -2
- data/hoy/Procfile.dev +0 -2
- data/hoy/README.md +0 -61
- data/hoy/Rakefile +0 -5
- data/hoy/app.rb +0 -116
- data/hoy/app/graphql/mutations/.keep +0 -0
- data/hoy/app/graphql/mutations/base/article/create_article.rb +0 -30
- data/hoy/app/graphql/mutations/base/article/delete_article.rb +0 -17
- data/hoy/app/graphql/mutations/base/article/destroy_delete_article.rb +0 -17
- data/hoy/app/graphql/mutations/base/article/update_article.rb +0 -30
- data/hoy/app/graphql/mutations/base/article_category/create_article_category.rb +0 -21
- data/hoy/app/graphql/mutations/base/article_category/delete_article_category.rb +0 -17
- data/hoy/app/graphql/mutations/base/article_category/destroy_delete_article_category.rb +0 -17
- data/hoy/app/graphql/mutations/base/article_category/update_article_category.rb +0 -21
- data/hoy/app/graphql/mutations/base/user/create_user.rb +0 -31
- data/hoy/app/graphql/mutations/base/user/delete_user.rb +0 -17
- data/hoy/app/graphql/mutations/base/user/destroy_delete_user.rb +0 -17
- data/hoy/app/graphql/mutations/base/user/update_user.rb +0 -31
- data/hoy/app/graphql/mutations/base_mutation.rb +0 -33
- data/hoy/app/graphql/mutations/user_manager/add_user_role.rb +0 -22
- data/hoy/app/graphql/mutations/user_manager/remove_user_role.rb +0 -22
- data/hoy/app/graphql/mutations/user_manager/sign_in_user.rb +0 -45
- data/hoy/app/graphql/queries/article.rb +0 -13
- data/hoy/app/graphql/queries/article_categories.rb +0 -11
- data/hoy/app/graphql/queries/article_category.rb +0 -13
- data/hoy/app/graphql/queries/articles.rb +0 -11
- data/hoy/app/graphql/queries/base_query.rb +0 -9
- data/hoy/app/graphql/queries/me.rb +0 -11
- data/hoy/app/graphql/queries/user.rb +0 -13
- data/hoy/app/graphql/queries/users.rb +0 -11
- data/hoy/app/graphql/resolvers/article_category_search.rb +0 -41
- data/hoy/app/graphql/resolvers/article_search.rb +0 -57
- data/hoy/app/graphql/resolvers/base.rb +0 -17
- data/hoy/app/graphql/resolvers/user_search.rb +0 -63
- data/hoy/app/graphql/souls_api_schema.rb +0 -43
- data/hoy/app/graphql/types/.keep +0 -0
- data/hoy/app/graphql/types/article_category_type.rb +0 -12
- data/hoy/app/graphql/types/article_type.rb +0 -30
- data/hoy/app/graphql/types/base/base_argument.rb +0 -4
- data/hoy/app/graphql/types/base/base_enum.rb +0 -4
- data/hoy/app/graphql/types/base/base_field.rb +0 -5
- data/hoy/app/graphql/types/base/base_input_object.rb +0 -5
- data/hoy/app/graphql/types/base/base_interface.rb +0 -7
- data/hoy/app/graphql/types/base/base_object.rb +0 -6
- data/hoy/app/graphql/types/base/base_scalar.rb +0 -4
- data/hoy/app/graphql/types/base/base_union.rb +0 -4
- data/hoy/app/graphql/types/base/mutation_type.rb +0 -16
- data/hoy/app/graphql/types/base/query_type.rb +0 -18
- data/hoy/app/graphql/types/connections/article_category_connection.rb +0 -3
- data/hoy/app/graphql/types/connections/article_connection.rb +0 -3
- data/hoy/app/graphql/types/connections/base_connection.rb +0 -14
- data/hoy/app/graphql/types/connections/user_connection.rb +0 -3
- data/hoy/app/graphql/types/edges/article_category_edge.rb +0 -5
- data/hoy/app/graphql/types/edges/article_edge.rb +0 -5
- data/hoy/app/graphql/types/edges/base_edge.rb +0 -4
- data/hoy/app/graphql/types/edges/user_edge.rb +0 -5
- data/hoy/app/graphql/types/user_type.rb +0 -22
- data/hoy/app/models/article.rb +0 -4
- data/hoy/app/models/article_category.rb +0 -3
- data/hoy/app/models/user.rb +0 -19
- data/hoy/app/policies/application_policy.rb +0 -40
- data/hoy/app/policies/article_category_policy.rb +0 -31
- data/hoy/app/policies/article_policy.rb +0 -31
- data/hoy/app/policies/user_policy.rb +0 -35
- data/hoy/app/utils/association_loader.rb +0 -50
- data/hoy/app/utils/firebase_id_token.rb +0 -4
- data/hoy/app/utils/json_web_token.rb +0 -13
- data/hoy/app/utils/record_loader.rb +0 -10
- data/hoy/app/utils/souls_helper.rb +0 -96
- data/hoy/cloudbuild.yml +0 -32
- data/hoy/config.ru +0 -17
- data/hoy/config/database.yml +0 -33
- data/hoy/config/souls.rb +0 -4
- data/hoy/constants/areas.rb +0 -71
- data/hoy/constants/column_name_ja.rb +0 -27
- data/hoy/db/migrate/20200006095538_create_users.rb +0 -30
- data/hoy/db/migrate/20200712180236_create_article_categories.rb +0 -12
- data/hoy/db/migrate/20200714215521_create_articles.rb +0 -22
- data/hoy/db/schema.rb +0 -78
- data/hoy/db/seeds.rb +0 -44
- data/hoy/github/workflows/delivery.yml +0 -81
- data/hoy/log/.keep +0 -0
- data/hoy/spec/factories/article_categories.rb +0 -9
- data/hoy/spec/factories/articles.rb +0 -17
- data/hoy/spec/factories/users.rb +0 -23
- data/hoy/spec/models/article_category_spec.rb +0 -7
- data/hoy/spec/models/article_spec.rb +0 -7
- data/hoy/spec/models/user_spec.rb +0 -7
- data/hoy/spec/mutations/base/article_category_spec.rb +0 -46
- data/hoy/spec/mutations/base/article_spec.rb +0 -70
- data/hoy/spec/mutations/base/user_spec.rb +0 -76
- data/hoy/spec/policies/article_category_policy_spec.rb +0 -25
- data/hoy/spec/policies/article_policy_spec.rb +0 -25
- data/hoy/spec/policies/user_policy_spec.rb +0 -5
- data/hoy/spec/queries/article_category_spec.rb +0 -39
- data/hoy/spec/queries/article_spec.rb +0 -53
- data/hoy/spec/queries/user_spec.rb +0 -59
- data/hoy/spec/resolvers/article_category_search_spec.rb +0 -54
- data/hoy/spec/resolvers/article_search_spec.rb +0 -68
- data/hoy/spec/resolvers/user_search_spec.rb +0 -74
- data/hoy/spec/spec_helper.rb +0 -110
- data/hoy/tmp/.keep +0 -0
@@ -1,31 +0,0 @@
|
|
1
|
-
module Mutations
|
2
|
-
module Base::User
|
3
|
-
class CreateUser < BaseMutation
|
4
|
-
field :error, String, null: true
|
5
|
-
field :user_edge, Types::UserType.edge_type, null: false
|
6
|
-
|
7
|
-
argument :birthday, String, required: false
|
8
|
-
argument :email, String, required: false
|
9
|
-
argument :first_name, String, required: false
|
10
|
-
argument :first_name_kana, String, required: false
|
11
|
-
argument :first_name_kanji, String, required: false
|
12
|
-
argument :icon_url, String, required: false
|
13
|
-
argument :last_name, String, required: false
|
14
|
-
argument :last_name_kana, String, required: false
|
15
|
-
argument :last_name_kanji, String, required: false
|
16
|
-
argument :screen_name, String, required: false
|
17
|
-
argument :tel, String, required: false
|
18
|
-
argument :uid, String, required: false
|
19
|
-
argument :username, String, required: false
|
20
|
-
|
21
|
-
def resolve(**args)
|
22
|
-
data = ::User.new(args)
|
23
|
-
raise(StandardError, data.errors.full_messages) unless data.save
|
24
|
-
|
25
|
-
{ user_edge: { node: data } }
|
26
|
-
rescue StandardError => e
|
27
|
-
GraphQL::ExecutionError.new(e)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Mutations
|
2
|
-
module Base::User
|
3
|
-
class DeleteUser < BaseMutation
|
4
|
-
field :user, Types::UserType, null: false
|
5
|
-
argument :id, String, required: true
|
6
|
-
|
7
|
-
def resolve(**args)
|
8
|
-
_, data_id = SoulsApiSchema.from_global_id(args[:id])
|
9
|
-
user = ::User.find(data_id)
|
10
|
-
user.update(is_deleted: true)
|
11
|
-
{ user: ::User.find(data_id) }
|
12
|
-
rescue StandardError => e
|
13
|
-
GraphQL::ExecutionError.new(e)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Mutations
|
2
|
-
module Base::User
|
3
|
-
class DestroyDeleteUser < BaseMutation
|
4
|
-
field :user, Types::UserType, null: false
|
5
|
-
argument :id, String, required: true
|
6
|
-
|
7
|
-
def resolve(**args)
|
8
|
-
_, data_id = SoulsApiSchema.from_global_id(args[:id])
|
9
|
-
user = ::User.find(data_id)
|
10
|
-
user.destroy
|
11
|
-
{ user: user }
|
12
|
-
rescue StandardError => e
|
13
|
-
GraphQL::ExecutionError.new(e)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Mutations
|
2
|
-
module Base::User
|
3
|
-
class UpdateUser < BaseMutation
|
4
|
-
field :user_edge, Types::UserType.edge_type, null: false
|
5
|
-
|
6
|
-
argument :birthday, String, required: false
|
7
|
-
argument :email, String, required: false
|
8
|
-
argument :first_name, String, required: false
|
9
|
-
argument :first_name_kana, String, required: false
|
10
|
-
argument :first_name_kanji, String, required: false
|
11
|
-
argument :icon_url, String, required: false
|
12
|
-
argument :id, String, required: true
|
13
|
-
argument :last_name, String, required: false
|
14
|
-
argument :last_name_kana, String, required: false
|
15
|
-
argument :last_name_kanji, String, required: false
|
16
|
-
argument :screen_name, String, required: false
|
17
|
-
argument :tel, String, required: false
|
18
|
-
argument :uid, String, required: false
|
19
|
-
argument :username, String, required: false
|
20
|
-
|
21
|
-
def resolve(**args)
|
22
|
-
_, args[:id] = SoulsApiSchema.from_global_id(args[:id])
|
23
|
-
user = ::User.find(args[:id])
|
24
|
-
user.update(args)
|
25
|
-
{ user_edge: { node: ::User.find(args[:id]) } }
|
26
|
-
rescue StandardError => e
|
27
|
-
GraphQL::ExecutionError.new(e)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Mutations
|
2
|
-
class BaseMutation < GraphQL::Schema::RelayClassicMutation
|
3
|
-
argument_class Types::BaseArgument
|
4
|
-
field_class Types::BaseField
|
5
|
-
input_object_class Types::BaseInputObject
|
6
|
-
object_class Types::BaseObject
|
7
|
-
|
8
|
-
def fb_auth(token:)
|
9
|
-
FirebaseIdToken::Certificates.request!
|
10
|
-
sleep(3) if ENV["RACK_ENV"] == "development"
|
11
|
-
@payload = FirebaseIdToken::Signature.verify(token)
|
12
|
-
raise(ArgumentError, "Invalid or Missing Token") if @payload.blank?
|
13
|
-
|
14
|
-
@payload
|
15
|
-
end
|
16
|
-
|
17
|
-
def auth_check(context)
|
18
|
-
raise(GraphQL::ExecutionError, "You need to sign in!!") if context[:user].nil?
|
19
|
-
end
|
20
|
-
|
21
|
-
def get_token(token)
|
22
|
-
JsonWebToken.decode(token)
|
23
|
-
end
|
24
|
-
|
25
|
-
def production?
|
26
|
-
ENV["RACK_ENV"] == "production"
|
27
|
-
end
|
28
|
-
|
29
|
-
def get_instance_id
|
30
|
-
`curl http://metadata.google.internal/computeMetadata/v1/instance/id -H Metadata-Flavor:Google`
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Mutations
|
2
|
-
module UserManager
|
3
|
-
class AddUserRole < BaseMutation
|
4
|
-
argument :target_user_id, String, required: true
|
5
|
-
argument :user_roles, [String], required: true
|
6
|
-
|
7
|
-
field :user, Types::UserType, null: true
|
8
|
-
|
9
|
-
def resolve(**args)
|
10
|
-
check_user_permissions(context[:user], context[:user], :update_user_role?)
|
11
|
-
_, user_id = SoulsApiSchema.from_global_id(args[:target_user_id])
|
12
|
-
target_user = ::User.find(user_id)
|
13
|
-
target_user.roles << args[:user_roles].map(&:to_sym)
|
14
|
-
return { user: target_user } if target_user.save
|
15
|
-
|
16
|
-
raise
|
17
|
-
rescue StandardError => e
|
18
|
-
GraphQL::ExecutionError.new(e.to_s)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Mutations
|
2
|
-
module UserManager
|
3
|
-
class RemoveUserRole < BaseMutation
|
4
|
-
argument :target_user_id, String, required: true
|
5
|
-
argument :user_roles, [String], required: true
|
6
|
-
|
7
|
-
field :user, Types::UserType, null: true
|
8
|
-
|
9
|
-
def resolve(**args)
|
10
|
-
check_user_permissions(context[:user], context[:user], :update_user_role?)
|
11
|
-
_, user_id = SoulsApiSchema.from_global_id(args[:target_user_id])
|
12
|
-
target_user = ::User.find(user_id)
|
13
|
-
args[:user_roles].each { |role| target_user.roles.delete(role) }
|
14
|
-
return { user: target_user } if target_user.save
|
15
|
-
|
16
|
-
raise
|
17
|
-
rescue StandardError => e
|
18
|
-
GraphQL::ExecutionError.new(e.to_s)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module Mutations
|
2
|
-
module UserManager
|
3
|
-
class SignInUser < BaseMutation
|
4
|
-
field :status, String, null: false
|
5
|
-
field :token, String, null: true
|
6
|
-
field :user_role, String, null: true
|
7
|
-
field :username, String, null: true
|
8
|
-
argument :token, String, required: false
|
9
|
-
|
10
|
-
def resolve(token:)
|
11
|
-
fb_auth(token: token)
|
12
|
-
begin
|
13
|
-
user = ::User.find_by_uid(@payload["sub"])
|
14
|
-
user.update(icon_url: @payload["picture"], username: @payload["name"])
|
15
|
-
token_base = JsonWebToken.encode(user_id: user.id)
|
16
|
-
{
|
17
|
-
status: "ログイン成功!",
|
18
|
-
username: user.username,
|
19
|
-
token: token_base
|
20
|
-
}
|
21
|
-
rescue StandardError
|
22
|
-
user =
|
23
|
-
::User.new(
|
24
|
-
uid: @payload["sub"],
|
25
|
-
email: @payload["email"],
|
26
|
-
icon_url: @payload["picture"],
|
27
|
-
username: @payload["name"],
|
28
|
-
user_role: 4
|
29
|
-
)
|
30
|
-
if user.save
|
31
|
-
token = JsonWebToken.encode(user_id: user.id)
|
32
|
-
{
|
33
|
-
status: "ユーザー新規登録完了!",
|
34
|
-
username: user.username,
|
35
|
-
token: token,
|
36
|
-
user_role: user.user_role
|
37
|
-
}
|
38
|
-
else
|
39
|
-
{ status: user.errors.full_messages }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Queries
|
2
|
-
class Article < Queries::BaseQuery
|
3
|
-
type Types::ArticleType, null: false
|
4
|
-
argument :id, String, required: true
|
5
|
-
|
6
|
-
def resolve(**args)
|
7
|
-
_, data_id = SoulsApiSchema.from_global_id(args[:id])
|
8
|
-
::Article.find(data_id)
|
9
|
-
rescue StandardError => e
|
10
|
-
GraphQL::ExecutionError.new(e)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Queries
|
2
|
-
class ArticleCategory < Queries::BaseQuery
|
3
|
-
type Types::ArticleCategoryType, null: false
|
4
|
-
argument :id, String, required: true
|
5
|
-
|
6
|
-
def resolve(**args)
|
7
|
-
_, data_id = SoulsApiSchema.from_global_id(args[:id])
|
8
|
-
::ArticleCategory.find(data_id)
|
9
|
-
rescue StandardError => e
|
10
|
-
GraphQL::ExecutionError.new(e)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Queries
|
2
|
-
class User < Queries::BaseQuery
|
3
|
-
type Types::UserType, null: false
|
4
|
-
argument :id, String, required: true
|
5
|
-
|
6
|
-
def resolve(**args)
|
7
|
-
_, data_id = SoulsApiSchema.from_global_id(args[:id])
|
8
|
-
::User.find(data_id)
|
9
|
-
rescue StandardError => e
|
10
|
-
GraphQL::ExecutionError.new(e)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module Resolvers
|
2
|
-
class ArticleCategorySearch < Base
|
3
|
-
include SearchObject.module(:graphql)
|
4
|
-
scope { ::ArticleCategory.all }
|
5
|
-
type Types::ArticleCategoryType.connection_type, null: false
|
6
|
-
description "Search ArticleCategory"
|
7
|
-
|
8
|
-
class ArticleCategoryFilter < ::Types::BaseInputObject
|
9
|
-
argument :OR, [self], required: false
|
10
|
-
argument :end_date, String, required: false
|
11
|
-
argument :is_deleted, Boolean, required: false
|
12
|
-
argument :name, String, required: false
|
13
|
-
argument :start_date, String, required: false
|
14
|
-
argument :tags, [String], required: false
|
15
|
-
end
|
16
|
-
|
17
|
-
option :filter, type: ArticleCategoryFilter, with: :apply_filter
|
18
|
-
option :first, type: types.Int, with: :apply_first
|
19
|
-
option :skip, type: types.Int, with: :apply_skip
|
20
|
-
|
21
|
-
def apply_filter(scope, value)
|
22
|
-
branches = normalize_filters(value).inject { |acc, elem| acc.or(elem) }
|
23
|
-
scope.merge(branches)
|
24
|
-
end
|
25
|
-
|
26
|
-
def normalize_filters(value, branches = [])
|
27
|
-
scope = ::ArticleCategory.all
|
28
|
-
scope = scope.where(name: value[:name]) if value[:name]
|
29
|
-
scope = scope.where("tags @> ARRAY[?]::text[]", value[:tags]) if value[:tags]
|
30
|
-
scope = scope.where(is_deleted: value[:is_deleted]) unless value[:is_deleted].nil?
|
31
|
-
scope = scope.where("created_at >= ?", value[:start_date]) if value[:start_date]
|
32
|
-
scope = scope.where("created_at <= ?", value[:end_date]) if value[:end_date]
|
33
|
-
|
34
|
-
branches << scope
|
35
|
-
|
36
|
-
value[:OR].inject(branches) { |acc, elem| normalize_filters(elem, acc) } if value[:OR].present?
|
37
|
-
|
38
|
-
branches
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
module Resolvers
|
2
|
-
class ArticleSearch < Base
|
3
|
-
include SearchObject.module(:graphql)
|
4
|
-
scope { ::Article.all }
|
5
|
-
type Types::ArticleType.connection_type, null: false
|
6
|
-
description "Search Article"
|
7
|
-
|
8
|
-
class ArticleFilter < ::Types::BaseInputObject
|
9
|
-
argument :OR, [self], required: false
|
10
|
-
argument :article_category_id, String, required: false
|
11
|
-
argument :body, String, required: false
|
12
|
-
argument :end_date, String, required: false
|
13
|
-
argument :is_deleted, Boolean, required: false
|
14
|
-
argument :is_public, Boolean, required: false
|
15
|
-
argument :just_created, Boolean, required: false
|
16
|
-
argument :public_date, GraphQL::Types::ISO8601DateTime, required: false
|
17
|
-
argument :slag, String, required: false
|
18
|
-
argument :start_date, String, required: false
|
19
|
-
argument :tags, [String], required: false
|
20
|
-
argument :thumnail_url, String, required: false
|
21
|
-
argument :title, String, required: false
|
22
|
-
end
|
23
|
-
|
24
|
-
option :filter, type: ArticleFilter, with: :apply_filter
|
25
|
-
option :first, type: types.Int, with: :apply_first
|
26
|
-
option :skip, type: types.Int, with: :apply_skip
|
27
|
-
|
28
|
-
def apply_filter(scope, value)
|
29
|
-
branches = normalize_filters(value).inject { |acc, elem| acc.or(elem) }
|
30
|
-
scope.merge(branches)
|
31
|
-
end
|
32
|
-
|
33
|
-
def normalize_filters(value, branches = [])
|
34
|
-
scope = ::Article.all
|
35
|
-
scope = scope.where(title: value[:title]) if value[:title]
|
36
|
-
scope = scope.where(body: value[:body]) if value[:body]
|
37
|
-
scope = scope.where(thumnail_url: value[:thumnail_url]) if value[:thumnail_url]
|
38
|
-
scope = scope.where(public_date: value[:public_date]) if value[:public_date]
|
39
|
-
if value[:article_category_id]
|
40
|
-
scope = scope.where(article_category_id: decode_global_key(value[:article_category_id]))
|
41
|
-
end
|
42
|
-
scope = scope.where(is_public: value[:is_public]) unless value[:is_public].nil?
|
43
|
-
scope = scope.where(just_created: value[:just_created]) unless value[:just_created].nil?
|
44
|
-
scope = scope.where(slag: value[:slag]) if value[:slag]
|
45
|
-
scope = scope.where("tags @> ARRAY[?]::text[]", value[:tags]) if value[:tags]
|
46
|
-
scope = scope.where(is_deleted: value[:is_deleted]) unless value[:is_deleted].nil?
|
47
|
-
scope = scope.where("created_at >= ?", value[:start_date]) if value[:start_date]
|
48
|
-
scope = scope.where("created_at <= ?", value[:end_date]) if value[:end_date]
|
49
|
-
|
50
|
-
branches << scope
|
51
|
-
|
52
|
-
value[:OR].inject(branches) { |acc, elem| normalize_filters(elem, acc) } if value[:OR].present?
|
53
|
-
|
54
|
-
branches
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Resolvers
|
2
|
-
class Base < GraphQL::Schema::Resolver
|
3
|
-
# argument_class Arguments::Base
|
4
|
-
def decode_global_key(id)
|
5
|
-
_, data_id = SoulsApiSchema.from_global_id(id)
|
6
|
-
data_id
|
7
|
-
end
|
8
|
-
|
9
|
-
def apply_first(scope, value)
|
10
|
-
scope.limit(value)
|
11
|
-
end
|
12
|
-
|
13
|
-
def apply_skip(scope, value)
|
14
|
-
scope.offset(value)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|