souls 0.23.8 → 0.24.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/.gitignore +1 -1
- data/.irbrc +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +34 -5
- data/apps/api/.env.sample +7 -0
- data/apps/api/.gitignore +32 -0
- data/apps/api/.irbrc +4 -0
- data/apps/api/.rspec +3 -0
- data/apps/api/.rubocop.yml +132 -0
- data/apps/api/.ruby-version +1 -0
- data/apps/api/CODE_OF_CONDUCT.md +74 -0
- data/apps/api/Dockerfile +16 -0
- data/apps/api/Dockerfile.dev +17 -0
- data/apps/api/Gemfile +50 -0
- data/apps/api/Gemfile.lock +412 -0
- data/apps/api/LICENSE.txt +67 -0
- data/apps/api/Procfile +2 -0
- data/apps/api/Procfile.dev +2 -0
- data/apps/api/README.md +37 -0
- data/apps/api/Rakefile +5 -0
- data/apps/api/app.rb +114 -0
- data/apps/api/app/engines/notification_engine.rb +5 -0
- data/apps/api/app/graphql/mutations/.keep +0 -0
- data/apps/api/app/graphql/mutations/base/article/create_article.rb +30 -0
- data/apps/api/app/graphql/mutations/base/article/delete_article.rb +17 -0
- data/apps/api/app/graphql/mutations/base/article/destroy_delete_article.rb +17 -0
- data/apps/api/app/graphql/mutations/base/article/update_article.rb +30 -0
- data/apps/api/app/graphql/mutations/base/article_category/create_article_category.rb +21 -0
- data/apps/api/app/graphql/mutations/base/article_category/delete_article_category.rb +17 -0
- data/apps/api/app/graphql/mutations/base/article_category/destroy_delete_article_category.rb +17 -0
- data/apps/api/app/graphql/mutations/base/article_category/update_article_category.rb +21 -0
- data/apps/api/app/graphql/mutations/base/user/create_user.rb +31 -0
- data/apps/api/app/graphql/mutations/base/user/delete_user.rb +17 -0
- data/apps/api/app/graphql/mutations/base/user/destroy_delete_user.rb +17 -0
- data/apps/api/app/graphql/mutations/base/user/update_user.rb +31 -0
- data/apps/api/app/graphql/mutations/base_mutation.rb +65 -0
- data/apps/api/app/graphql/mutations/managers/user_manager/add_user_role.rb +22 -0
- data/apps/api/app/graphql/mutations/managers/user_manager/remove_user_role.rb +22 -0
- data/apps/api/app/graphql/mutations/managers/user_manager/sign_in_user.rb +45 -0
- data/apps/api/app/graphql/queries/article.rb +13 -0
- data/apps/api/app/graphql/queries/article_categories.rb +11 -0
- data/apps/api/app/graphql/queries/article_category.rb +13 -0
- data/apps/api/app/graphql/queries/articles.rb +11 -0
- data/apps/api/app/graphql/queries/base_query.rb +12 -0
- data/apps/api/app/graphql/queries/me.rb +11 -0
- data/apps/api/app/graphql/queries/user.rb +13 -0
- data/apps/api/app/graphql/queries/users.rb +11 -0
- data/apps/api/app/graphql/resolvers/article_category_search.rb +41 -0
- data/apps/api/app/graphql/resolvers/article_search.rb +57 -0
- data/apps/api/app/graphql/resolvers/base.rb +17 -0
- data/apps/api/app/graphql/resolvers/user_search.rb +63 -0
- data/apps/api/app/graphql/souls_api_schema.rb +43 -0
- data/apps/api/app/graphql/types/.keep +0 -0
- data/apps/api/app/graphql/types/article_category_type.rb +12 -0
- data/apps/api/app/graphql/types/article_type.rb +30 -0
- data/apps/api/app/graphql/types/base/base_argument.rb +4 -0
- data/apps/api/app/graphql/types/base/base_enum.rb +4 -0
- data/apps/api/app/graphql/types/base/base_field.rb +5 -0
- data/apps/api/app/graphql/types/base/base_input_object.rb +5 -0
- data/apps/api/app/graphql/types/base/base_interface.rb +7 -0
- data/apps/api/app/graphql/types/base/base_object.rb +6 -0
- data/apps/api/app/graphql/types/base/base_scalar.rb +4 -0
- data/apps/api/app/graphql/types/base/base_union.rb +4 -0
- data/apps/api/app/graphql/types/base/mutation_type.rb +26 -0
- data/apps/api/app/graphql/types/base/query_type.rb +18 -0
- data/apps/api/app/graphql/types/connections/article_category_connection.rb +3 -0
- data/apps/api/app/graphql/types/connections/article_connection.rb +3 -0
- data/apps/api/app/graphql/types/connections/base_connection.rb +14 -0
- data/apps/api/app/graphql/types/connections/user_connection.rb +3 -0
- data/apps/api/app/graphql/types/edges/article_category_edge.rb +5 -0
- data/apps/api/app/graphql/types/edges/article_edge.rb +5 -0
- data/apps/api/app/graphql/types/edges/base_edge.rb +4 -0
- data/apps/api/app/graphql/types/edges/user_edge.rb +5 -0
- data/apps/api/app/graphql/types/user_type.rb +24 -0
- data/apps/api/app/models/article.rb +4 -0
- data/apps/api/app/models/article_category.rb +3 -0
- data/apps/api/app/models/user.rb +19 -0
- data/apps/api/app/policies/application_policy.rb +40 -0
- data/apps/api/app/policies/article_category_policy.rb +31 -0
- data/apps/api/app/policies/article_policy.rb +31 -0
- data/apps/api/app/policies/user_policy.rb +35 -0
- data/apps/api/app/utils/association_loader.rb +50 -0
- data/apps/api/app/utils/fire_store.rb +9 -0
- data/apps/api/app/utils/firebase_id_token.rb +4 -0
- data/apps/api/app/utils/json_web_token.rb +13 -0
- data/apps/api/app/utils/record_loader.rb +10 -0
- data/apps/api/app/utils/souls_helper.rb +18 -0
- data/apps/api/cloudbuild.yml +32 -0
- data/apps/api/config.ru +17 -0
- data/apps/api/config/database.yml +33 -0
- data/apps/api/config/souls.rb +10 -0
- data/apps/api/constants/areas.rb +71 -0
- data/apps/api/constants/column_name_ja.rb +27 -0
- data/apps/api/db/migrate/20200006095538_create_users.rb +30 -0
- data/apps/api/db/migrate/20200712180236_create_article_categories.rb +12 -0
- data/apps/api/db/migrate/20200714215521_create_articles.rb +22 -0
- data/apps/api/db/schema.rb +78 -0
- data/apps/api/db/seeds.rb +44 -0
- data/apps/api/github/workflows/delivery.yml +81 -0
- data/apps/api/log/.keep +0 -0
- data/apps/api/spec/factories/article_categories.rb +9 -0
- data/apps/api/spec/factories/articles.rb +17 -0
- data/apps/api/spec/factories/users.rb +23 -0
- data/apps/api/spec/models/article_category_spec.rb +7 -0
- data/apps/api/spec/models/article_spec.rb +7 -0
- data/apps/api/spec/models/user_spec.rb +7 -0
- data/apps/api/spec/mutations/base/article_category_spec.rb +46 -0
- data/apps/api/spec/mutations/base/article_spec.rb +70 -0
- data/apps/api/spec/mutations/base/user_spec.rb +76 -0
- data/apps/api/spec/policies/article_category_policy_spec.rb +24 -0
- data/apps/api/spec/policies/article_policy_spec.rb +24 -0
- data/apps/api/spec/policies/user_policy_spec.rb +24 -0
- data/apps/api/spec/queries/article_category_spec.rb +39 -0
- data/apps/api/spec/queries/article_spec.rb +53 -0
- data/apps/api/spec/queries/user_spec.rb +59 -0
- data/apps/api/spec/resolvers/article_category_search_spec.rb +54 -0
- data/apps/api/spec/resolvers/article_search_spec.rb +68 -0
- data/apps/api/spec/resolvers/user_search_spec.rb +74 -0
- data/apps/api/spec/spec_helper.rb +110 -0
- data/apps/api/tmp/.keep +0 -0
- data/apps/worker/.env.sample +9 -0
- data/apps/worker/.gitignore +32 -0
- data/apps/worker/.irbrc +4 -0
- data/apps/worker/.rspec +3 -0
- data/apps/worker/.rubocop.yml +132 -0
- data/apps/worker/.ruby-version +1 -0
- data/apps/worker/CODE_OF_CONDUCT.md +74 -0
- data/apps/worker/Dockerfile +16 -0
- data/apps/worker/Dockerfile.dev +17 -0
- data/apps/worker/Gemfile +49 -0
- data/apps/worker/Gemfile.lock +396 -0
- data/apps/worker/LICENSE.txt +67 -0
- data/apps/worker/Procfile +1 -0
- data/apps/worker/Procfile.dev +1 -0
- data/apps/worker/README.md +37 -0
- data/apps/worker/Rakefile +5 -0
- data/apps/worker/app.rb +101 -0
- data/apps/worker/app/engines/notification_engine.rb +5 -0
- data/apps/worker/app/graphql/mutations/.keep +0 -0
- data/apps/worker/app/graphql/mutations/base_mutation.rb +16 -0
- data/apps/worker/app/graphql/mutations/workers/send_user_mail_job.rb +31 -0
- data/apps/worker/app/graphql/souls_api_schema.rb +43 -0
- data/apps/worker/app/graphql/types/.keep +0 -0
- data/apps/worker/app/graphql/types/base/base_argument.rb +4 -0
- data/apps/worker/app/graphql/types/base/base_enum.rb +4 -0
- data/apps/worker/app/graphql/types/base/base_field.rb +5 -0
- data/apps/worker/app/graphql/types/base/base_input_object.rb +5 -0
- data/apps/worker/app/graphql/types/base/base_interface.rb +7 -0
- data/apps/worker/app/graphql/types/base/base_object.rb +5 -0
- data/apps/worker/app/graphql/types/base/base_scalar.rb +4 -0
- data/apps/worker/app/graphql/types/base/base_union.rb +4 -0
- data/apps/worker/app/graphql/types/base/mutation_type.rb +12 -0
- data/apps/worker/app/graphql/types/base/query_type.rb +6 -0
- data/apps/worker/app/models/article.rb +4 -0
- data/apps/worker/app/models/article_category.rb +3 -0
- data/apps/worker/app/models/user.rb +19 -0
- data/apps/worker/app/utils/fire_store.rb +9 -0
- data/apps/worker/app/utils/souls_helper.rb +96 -0
- data/apps/worker/cloudbuild.yml +32 -0
- data/apps/worker/config.ru +17 -0
- data/apps/worker/config/database.yml +33 -0
- data/apps/worker/config/souls.rb +10 -0
- data/apps/worker/db/migrate/20200006095538_create_users.rb +30 -0
- data/apps/worker/db/migrate/20200712180236_create_article_categories.rb +12 -0
- data/apps/worker/db/migrate/20200714215521_create_articles.rb +22 -0
- data/apps/worker/db/schema.rb +78 -0
- data/apps/worker/db/seeds.rb +44 -0
- data/apps/worker/github/workflows/delivery.yml +81 -0
- data/apps/worker/log/.keep +0 -0
- data/apps/worker/spec/factories/article_categories.rb +9 -0
- data/apps/worker/spec/factories/articles.rb +17 -0
- data/apps/worker/spec/factories/users.rb +23 -0
- data/apps/worker/spec/models/article_category_spec.rb +7 -0
- data/apps/worker/spec/models/article_spec.rb +7 -0
- data/apps/worker/spec/models/user_spec.rb +7 -0
- data/apps/worker/spec/spec_helper.rb +110 -0
- data/apps/worker/tmp/.keep +0 -0
- data/config/souls.rb +7 -3
- data/exe/souls +16 -3
- data/lib/souls.rb +129 -140
- data/lib/souls/gcloud.rb +1 -0
- data/lib/souls/gcloud/compute.rb +62 -60
- data/lib/souls/gcloud/iam.rb +38 -22
- data/lib/souls/gcloud/pubsub.rb +21 -0
- data/lib/souls/init.rb +1 -16
- data/lib/souls/version.rb +1 -1
- metadata +176 -2
data/apps/api/Procfile
ADDED
data/apps/api/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# SOULs Serverless GraphQL API Boilerplate
|
2
|
+
SOULs Serverless GraphQL API Boilerplate
|
3
|
+
|
4
|
+
<p align="center">
|
5
|
+
|
6
|
+
<a aria-label="Ruby logo" href="https://el-soul.com">
|
7
|
+
<img src="https://badgen.net/badge/icon/Made%20by%20ELSOUL?icon=ruby&label&color=black&labelColor=black">
|
8
|
+
</a>
|
9
|
+
<br/>
|
10
|
+
</p>
|
11
|
+
|
12
|
+
|
13
|
+
## SOULs Document
|
14
|
+
|
15
|
+
- [SOULs Document](https://souls.elsoul.nl/)
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
## Development
|
22
|
+
|
23
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
24
|
+
|
25
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org/gems/souls).
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/elsoul/souls_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
30
|
+
|
31
|
+
## License
|
32
|
+
|
33
|
+
The gem is available as open source under the terms of the [Apache-2.0 License](https://www.apache.org/licenses/LICENSE-2.0).
|
34
|
+
|
35
|
+
## Code of Conduct
|
36
|
+
|
37
|
+
Everyone interacting in the HotelPrice project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/elsoul/souls/blob/master/CODE_OF_CONDUCT.md).
|
data/apps/api/Rakefile
ADDED
data/apps/api/app.rb
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
require "active_support"
|
2
|
+
require "active_support/core_ext"
|
3
|
+
require "erb"
|
4
|
+
require "jwt"
|
5
|
+
require "json"
|
6
|
+
require "sinatra"
|
7
|
+
require "sinatra/base"
|
8
|
+
require "sinatra/json"
|
9
|
+
require "sinatra/activerecord"
|
10
|
+
require "rack/contrib"
|
11
|
+
require "zeitwerk"
|
12
|
+
require "factory_bot"
|
13
|
+
require "faker"
|
14
|
+
require "dotenv/load"
|
15
|
+
require "firebase_id_token"
|
16
|
+
require "graphql"
|
17
|
+
require "google/cloud/firestore"
|
18
|
+
require "google/cloud/storage"
|
19
|
+
require "google/cloud/pubsub"
|
20
|
+
require "logger"
|
21
|
+
require "base64"
|
22
|
+
require "slack/ruby3"
|
23
|
+
require "role_model"
|
24
|
+
require "pundit"
|
25
|
+
require "sendgrid-ruby"
|
26
|
+
require "search_object"
|
27
|
+
require "search_object/plugin/graphql"
|
28
|
+
require "graphql/batch"
|
29
|
+
|
30
|
+
ENV["RACK_ENV"] ||= "development"
|
31
|
+
Dir["./config/*.rb"].each { |f| require f unless f.include?("souls.rb") }
|
32
|
+
Dir["./constants/*.rb"].each { |f| require f }
|
33
|
+
|
34
|
+
db_conf = YAML.safe_load(ERB.new(File.read("./config/database.yml")).result, permitted_classes: [Date], aliases: true)
|
35
|
+
ActiveRecord::Base.establish_connection(db_conf[ENV["RACK_ENV"]])
|
36
|
+
ActiveRecord::Base.default_timezone = :local
|
37
|
+
|
38
|
+
loader = Zeitwerk::Loader.new
|
39
|
+
loader.push_dir("#{Dir.pwd}/app/models")
|
40
|
+
loader.push_dir("#{Dir.pwd}/app/utils")
|
41
|
+
loader.push_dir("#{Dir.pwd}/app/engines")
|
42
|
+
loader.push_dir("#{Dir.pwd}/app/policies")
|
43
|
+
|
44
|
+
loader.collapse("#{__dir__}/app/types")
|
45
|
+
loader.collapse("#{__dir__}/app/mutations")
|
46
|
+
loader.collapse("#{__dir__}/app/queries")
|
47
|
+
loader.collapse("#{__dir__}/app/resolvers")
|
48
|
+
loader.collapse("#{__dir__}/app/graphql/types/connections")
|
49
|
+
loader.collapse("#{__dir__}/app/graphql/types/edges")
|
50
|
+
loader.collapse("#{__dir__}/app/graphql/types/base")
|
51
|
+
loader.push_dir("#{Dir.pwd}/app/graphql")
|
52
|
+
loader.setup
|
53
|
+
|
54
|
+
class SoulsApi < Sinatra::Base
|
55
|
+
include Pundit
|
56
|
+
include SoulsHelper
|
57
|
+
::Logger.class_eval { alias_method :write, :<< }
|
58
|
+
access_log = ::File.join(::File.dirname(::File.expand_path(__FILE__)), "log", "access.log")
|
59
|
+
access_logger = ::Logger.new(access_log)
|
60
|
+
error_logger = ::File.new(::File.join(::File.dirname(::File.expand_path(__FILE__)), "log", "error.log"), "a+")
|
61
|
+
error_logger.sync = true
|
62
|
+
|
63
|
+
use Rack::JSONBodyParser
|
64
|
+
register Sinatra::ActiveRecordExtension
|
65
|
+
|
66
|
+
configure :production, :development do
|
67
|
+
set :logger, Logger.new($stdout)
|
68
|
+
enable :logging
|
69
|
+
use ::Rack::CommonLogger, access_logger
|
70
|
+
end
|
71
|
+
|
72
|
+
before { env["rack.errors"] = error_logger }
|
73
|
+
|
74
|
+
error StandardError do
|
75
|
+
StandardError.to_json
|
76
|
+
end
|
77
|
+
|
78
|
+
get "/" do
|
79
|
+
message = { success: true, message: "SOULs Running!", env: ENV["RACK_ENV"] }
|
80
|
+
json message
|
81
|
+
end
|
82
|
+
|
83
|
+
get "/db" do
|
84
|
+
message = { success: true, message: "SOULs Running!", env: ENV["RACK_ENV"], db: User.first.username }
|
85
|
+
json(message)
|
86
|
+
rescue StandardError => e
|
87
|
+
message = { error: e }
|
88
|
+
json(message)
|
89
|
+
end
|
90
|
+
|
91
|
+
post "/endpoint" do
|
92
|
+
token = request.env["HTTP_AUTHORIZATION"].split("Bearer ")[1] if request.env["HTTP_AUTHORIZATION"]
|
93
|
+
|
94
|
+
user = token ? login_auth(token: token) : nil
|
95
|
+
context = { user: user }
|
96
|
+
result = SoulsApiSchema.execute(params[:query], variables: params[:variables], context: context)
|
97
|
+
json(result)
|
98
|
+
rescue StandardError => e
|
99
|
+
message = { error: e }
|
100
|
+
json(message)
|
101
|
+
end
|
102
|
+
|
103
|
+
def login_auth(token:)
|
104
|
+
decoded_token = JsonWebToken.decode(token)
|
105
|
+
user_id = decoded_token[:user_id]
|
106
|
+
user = User.find(user_id)
|
107
|
+
raise(StandardError, "Invalid or Missing Token") if user.blank?
|
108
|
+
|
109
|
+
user
|
110
|
+
rescue StandardError => e
|
111
|
+
message = { error: e }
|
112
|
+
json(message)
|
113
|
+
end
|
114
|
+
end
|
File without changes
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Mutations
|
2
|
+
module Base::Article
|
3
|
+
class CreateArticle < BaseMutation
|
4
|
+
field :article_edge, Types::ArticleType.edge_type, null: false
|
5
|
+
field :error, String, null: true
|
6
|
+
|
7
|
+
argument :article_category_id, String, required: false
|
8
|
+
argument :body, String, required: false
|
9
|
+
argument :is_deleted, Boolean, required: false
|
10
|
+
argument :is_public, Boolean, required: false
|
11
|
+
argument :just_created, Boolean, required: false
|
12
|
+
argument :public_date, String, required: false
|
13
|
+
argument :slag, String, required: false
|
14
|
+
argument :tags, [String], required: false
|
15
|
+
argument :thumnail_url, String, required: false
|
16
|
+
argument :title, String, required: false
|
17
|
+
|
18
|
+
def resolve(**args)
|
19
|
+
args[:user_id] = context[:user].id
|
20
|
+
_, args[:article_category_id] = SoulsApiSchema.from_global_id(args[:article_category_id])
|
21
|
+
data = ::Article.new(args)
|
22
|
+
raise(StandardError, data.errors.full_messages) unless data.save
|
23
|
+
|
24
|
+
{ article_edge: { node: data } }
|
25
|
+
rescue StandardError => e
|
26
|
+
GraphQL::ExecutionError.new(e)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Mutations
|
2
|
+
module Base::Article
|
3
|
+
class DeleteArticle < BaseMutation
|
4
|
+
field :article, Types::ArticleType, null: false
|
5
|
+
argument :id, String, required: true
|
6
|
+
|
7
|
+
def resolve(**args)
|
8
|
+
_, data_id = SoulsApiSchema.from_global_id(args[:id])
|
9
|
+
article = ::Article.find(data_id)
|
10
|
+
article.update(is_deleted: true)
|
11
|
+
{ article: ::Article.find(data_id) }
|
12
|
+
rescue StandardError => e
|
13
|
+
GraphQL::ExecutionError.new(e)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Mutations
|
2
|
+
module Base::Article
|
3
|
+
class DestroyDeleteArticle < BaseMutation
|
4
|
+
field :article, Types::ArticleType, null: false
|
5
|
+
argument :id, String, required: true
|
6
|
+
|
7
|
+
def resolve(**args)
|
8
|
+
_, data_id = SoulsApiSchema.from_global_id(args[:id])
|
9
|
+
article = ::Article.find(data_id)
|
10
|
+
article.destroy
|
11
|
+
{ article: article }
|
12
|
+
rescue StandardError => e
|
13
|
+
GraphQL::ExecutionError.new(e)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Mutations
|
2
|
+
module Base::Article
|
3
|
+
class UpdateArticle < BaseMutation
|
4
|
+
field :article_edge, Types::ArticleType.edge_type, null: false
|
5
|
+
|
6
|
+
argument :article_category_id, String, required: false
|
7
|
+
argument :body, String, required: false
|
8
|
+
argument :id, String, required: true
|
9
|
+
argument :is_deleted, Boolean, required: false
|
10
|
+
argument :is_public, Boolean, required: false
|
11
|
+
argument :just_created, Boolean, required: false
|
12
|
+
argument :public_date, GraphQL::Types::ISO8601DateTime, required: false
|
13
|
+
argument :slag, String, required: false
|
14
|
+
argument :tags, [String], required: false
|
15
|
+
argument :thumnail_url, String, required: false
|
16
|
+
argument :title, String, required: false
|
17
|
+
|
18
|
+
def resolve(**args)
|
19
|
+
args[:user_id] = context[:user].id
|
20
|
+
_, args[:id] = SoulsApiSchema.from_global_id(args[:id])
|
21
|
+
_, args[:article_category_id] = SoulsApiSchema.from_global_id(args[:article_category_id])
|
22
|
+
article = ::Article.find(args[:id])
|
23
|
+
article.update(args)
|
24
|
+
{ article_edge: { node: ::Article.find(args[:id]) } }
|
25
|
+
rescue StandardError => e
|
26
|
+
GraphQL::ExecutionError.new(e)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Mutations
|
2
|
+
module Base::ArticleCategory
|
3
|
+
class CreateArticleCategory < BaseMutation
|
4
|
+
field :article_category_edge, Types::ArticleCategoryType.edge_type, null: false
|
5
|
+
field :error, String, null: true
|
6
|
+
|
7
|
+
argument :is_deleted, Boolean, required: false
|
8
|
+
argument :name, String, required: false
|
9
|
+
argument :tags, [String], required: false
|
10
|
+
|
11
|
+
def resolve(**args)
|
12
|
+
data = ::ArticleCategory.new(args)
|
13
|
+
raise(StandardError, data.errors.full_messages) unless data.save
|
14
|
+
|
15
|
+
{ article_category_edge: { node: data } }
|
16
|
+
rescue StandardError => e
|
17
|
+
GraphQL::ExecutionError.new(e)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Mutations
|
2
|
+
module Base::ArticleCategory
|
3
|
+
class DeleteArticleCategory < BaseMutation
|
4
|
+
field :article_category, Types::ArticleCategoryType, null: false
|
5
|
+
argument :id, String, required: true
|
6
|
+
|
7
|
+
def resolve(**args)
|
8
|
+
_, data_id = SoulsApiSchema.from_global_id(args[:id])
|
9
|
+
article_category = ::ArticleCategory.find(data_id)
|
10
|
+
article_category.update(is_deleted: true)
|
11
|
+
{ article_category: ::ArticleCategory.find(data_id) }
|
12
|
+
rescue StandardError => e
|
13
|
+
GraphQL::ExecutionError.new(e)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Mutations
|
2
|
+
module Base::ArticleCategory
|
3
|
+
class DestroyDeleteArticleCategory < BaseMutation
|
4
|
+
field :article_category, Types::ArticleCategoryType, null: false
|
5
|
+
argument :id, String, required: true
|
6
|
+
|
7
|
+
def resolve(**args)
|
8
|
+
_, data_id = SoulsApiSchema.from_global_id(args[:id])
|
9
|
+
article_category = ::ArticleCategory.find(data_id)
|
10
|
+
article_category.destroy
|
11
|
+
{ article_category: article_category }
|
12
|
+
rescue StandardError => e
|
13
|
+
GraphQL::ExecutionError.new(e)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Mutations
|
2
|
+
module Base::ArticleCategory
|
3
|
+
class UpdateArticleCategory < BaseMutation
|
4
|
+
field :article_category_edge, Types::ArticleCategoryType.edge_type, null: false
|
5
|
+
|
6
|
+
argument :id, String, required: true
|
7
|
+
argument :is_deleted, Boolean, required: false
|
8
|
+
argument :name, String, required: false
|
9
|
+
argument :tags, [String], required: false
|
10
|
+
|
11
|
+
def resolve(**args)
|
12
|
+
_, args[:id] = SoulsApiSchema.from_global_id(args[:id])
|
13
|
+
article_category = ::ArticleCategory.find(args[:id])
|
14
|
+
article_category.update(args)
|
15
|
+
{ article_category_edge: { node: ::ArticleCategory.find(args[:id]) } }
|
16
|
+
rescue StandardError => e
|
17
|
+
GraphQL::ExecutionError.new(e)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
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
|
@@ -0,0 +1,17 @@
|
|
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
|
@@ -0,0 +1,17 @@
|
|
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
|
@@ -0,0 +1,31 @@
|
|
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
|