souls 0.22.6 → 0.22.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/exe/souls +21 -5
  4. data/hoy/.env.sample +7 -0
  5. data/hoy/.gitignore +32 -0
  6. data/hoy/.irbrc +1 -0
  7. data/hoy/.rspec +3 -0
  8. data/hoy/.rubocop.yml +132 -0
  9. data/hoy/.ruby-version +1 -0
  10. data/hoy/CODE_OF_CONDUCT.md +74 -0
  11. data/hoy/Dockerfile +16 -0
  12. data/hoy/Dockerfile.dev +17 -0
  13. data/hoy/Gemfile +50 -0
  14. data/hoy/Gemfile.lock +407 -0
  15. data/hoy/LICENSE.txt +67 -0
  16. data/hoy/Procfile +2 -0
  17. data/hoy/Procfile.dev +2 -0
  18. data/hoy/README.md +61 -0
  19. data/hoy/Rakefile +5 -0
  20. data/hoy/app.rb +116 -0
  21. data/hoy/app/graphql/mutations/.keep +0 -0
  22. data/hoy/app/graphql/mutations/base/article/create_article.rb +30 -0
  23. data/hoy/app/graphql/mutations/base/article/delete_article.rb +17 -0
  24. data/hoy/app/graphql/mutations/base/article/destroy_delete_article.rb +17 -0
  25. data/hoy/app/graphql/mutations/base/article/update_article.rb +30 -0
  26. data/hoy/app/graphql/mutations/base/article_category/create_article_category.rb +21 -0
  27. data/hoy/app/graphql/mutations/base/article_category/delete_article_category.rb +17 -0
  28. data/hoy/app/graphql/mutations/base/article_category/destroy_delete_article_category.rb +17 -0
  29. data/hoy/app/graphql/mutations/base/article_category/update_article_category.rb +21 -0
  30. data/hoy/app/graphql/mutations/base/user/create_user.rb +31 -0
  31. data/hoy/app/graphql/mutations/base/user/delete_user.rb +17 -0
  32. data/hoy/app/graphql/mutations/base/user/destroy_delete_user.rb +17 -0
  33. data/hoy/app/graphql/mutations/base/user/update_user.rb +31 -0
  34. data/hoy/app/graphql/mutations/base_mutation.rb +33 -0
  35. data/hoy/app/graphql/mutations/user_manager/add_user_role.rb +22 -0
  36. data/hoy/app/graphql/mutations/user_manager/remove_user_role.rb +22 -0
  37. data/hoy/app/graphql/mutations/user_manager/sign_in_user.rb +45 -0
  38. data/hoy/app/graphql/queries/article.rb +13 -0
  39. data/hoy/app/graphql/queries/article_categories.rb +11 -0
  40. data/hoy/app/graphql/queries/article_category.rb +13 -0
  41. data/hoy/app/graphql/queries/articles.rb +11 -0
  42. data/hoy/app/graphql/queries/base_query.rb +9 -0
  43. data/hoy/app/graphql/queries/me.rb +11 -0
  44. data/hoy/app/graphql/queries/user.rb +13 -0
  45. data/hoy/app/graphql/queries/users.rb +11 -0
  46. data/hoy/app/graphql/resolvers/article_category_search.rb +41 -0
  47. data/hoy/app/graphql/resolvers/article_search.rb +57 -0
  48. data/hoy/app/graphql/resolvers/base.rb +17 -0
  49. data/hoy/app/graphql/resolvers/user_search.rb +63 -0
  50. data/hoy/app/graphql/souls_api_schema.rb +43 -0
  51. data/hoy/app/graphql/types/.keep +0 -0
  52. data/hoy/app/graphql/types/article_category_type.rb +12 -0
  53. data/hoy/app/graphql/types/article_type.rb +30 -0
  54. data/hoy/app/graphql/types/base/base_argument.rb +4 -0
  55. data/hoy/app/graphql/types/base/base_enum.rb +4 -0
  56. data/hoy/app/graphql/types/base/base_field.rb +5 -0
  57. data/hoy/app/graphql/types/base/base_input_object.rb +5 -0
  58. data/hoy/app/graphql/types/base/base_interface.rb +7 -0
  59. data/hoy/app/graphql/types/base/base_object.rb +6 -0
  60. data/hoy/app/graphql/types/base/base_scalar.rb +4 -0
  61. data/hoy/app/graphql/types/base/base_union.rb +4 -0
  62. data/hoy/app/graphql/types/base/mutation_type.rb +16 -0
  63. data/hoy/app/graphql/types/base/query_type.rb +18 -0
  64. data/hoy/app/graphql/types/connections/article_category_connection.rb +3 -0
  65. data/hoy/app/graphql/types/connections/article_connection.rb +3 -0
  66. data/hoy/app/graphql/types/connections/base_connection.rb +14 -0
  67. data/hoy/app/graphql/types/connections/user_connection.rb +3 -0
  68. data/hoy/app/graphql/types/edges/article_category_edge.rb +5 -0
  69. data/hoy/app/graphql/types/edges/article_edge.rb +5 -0
  70. data/hoy/app/graphql/types/edges/base_edge.rb +4 -0
  71. data/hoy/app/graphql/types/edges/user_edge.rb +5 -0
  72. data/hoy/app/graphql/types/user_type.rb +22 -0
  73. data/hoy/app/models/article.rb +4 -0
  74. data/hoy/app/models/article_category.rb +3 -0
  75. data/hoy/app/models/user.rb +19 -0
  76. data/hoy/app/policies/application_policy.rb +40 -0
  77. data/hoy/app/policies/article_category_policy.rb +31 -0
  78. data/hoy/app/policies/article_policy.rb +31 -0
  79. data/hoy/app/policies/user_policy.rb +35 -0
  80. data/hoy/app/utils/association_loader.rb +50 -0
  81. data/hoy/app/utils/firebase_id_token.rb +4 -0
  82. data/hoy/app/utils/json_web_token.rb +13 -0
  83. data/hoy/app/utils/record_loader.rb +10 -0
  84. data/hoy/app/utils/souls_helper.rb +96 -0
  85. data/hoy/cloudbuild.yml +32 -0
  86. data/hoy/config.ru +17 -0
  87. data/hoy/config/database.yml +33 -0
  88. data/hoy/config/souls.rb +4 -0
  89. data/hoy/constants/areas.rb +71 -0
  90. data/hoy/constants/column_name_ja.rb +27 -0
  91. data/hoy/db/migrate/20200006095538_create_users.rb +30 -0
  92. data/hoy/db/migrate/20200712180236_create_article_categories.rb +12 -0
  93. data/hoy/db/migrate/20200714215521_create_articles.rb +22 -0
  94. data/hoy/db/schema.rb +78 -0
  95. data/hoy/db/seeds.rb +44 -0
  96. data/hoy/github/workflows/delivery.yml +81 -0
  97. data/hoy/log/.keep +0 -0
  98. data/hoy/spec/factories/article_categories.rb +9 -0
  99. data/hoy/spec/factories/articles.rb +17 -0
  100. data/hoy/spec/factories/users.rb +23 -0
  101. data/hoy/spec/models/article_category_spec.rb +7 -0
  102. data/hoy/spec/models/article_spec.rb +7 -0
  103. data/hoy/spec/models/user_spec.rb +7 -0
  104. data/hoy/spec/mutations/base/article_category_spec.rb +46 -0
  105. data/hoy/spec/mutations/base/article_spec.rb +70 -0
  106. data/hoy/spec/mutations/base/user_spec.rb +76 -0
  107. data/hoy/spec/policies/article_category_policy_spec.rb +25 -0
  108. data/hoy/spec/policies/article_policy_spec.rb +25 -0
  109. data/hoy/spec/policies/user_policy_spec.rb +5 -0
  110. data/hoy/spec/queries/article_category_spec.rb +39 -0
  111. data/hoy/spec/queries/article_spec.rb +53 -0
  112. data/hoy/spec/queries/user_spec.rb +59 -0
  113. data/hoy/spec/resolvers/article_category_search_spec.rb +54 -0
  114. data/hoy/spec/resolvers/article_search_spec.rb +68 -0
  115. data/hoy/spec/resolvers/user_search_spec.rb +74 -0
  116. data/hoy/spec/spec_helper.rb +110 -0
  117. data/hoy/tmp/.keep +0 -0
  118. data/lib/souls/init.rb +16 -9
  119. data/lib/souls/version.rb +1 -1
  120. metadata +115 -1
data/hoy/LICENSE.txt ADDED
@@ -0,0 +1,67 @@
1
+ Apache License
2
+
3
+ Version 2.0, January 2004
4
+
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
16
+
17
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
18
+
19
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
20
+
21
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
22
+
23
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
24
+
25
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
26
+
27
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
28
+
29
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
30
+
31
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
32
+
33
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
34
+
35
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
36
+
37
+ You must give any other recipients of the Work or Derivative Works a copy of this License; and
38
+ You must cause any modified files to carry prominent notices stating that You changed the files; and
39
+ You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
40
+ If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
41
+
42
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
43
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
44
+
45
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
46
+
47
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
48
+
49
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
50
+
51
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
52
+
53
+ END OF TERMS AND CONDITIONS
54
+
55
+ Copyright 2021 ELSOUL LABO B.V.
56
+
57
+ Licensed under the Apache License, Version 2.0 (the "License");
58
+ you may not use this file except in compliance with the License.
59
+ You may obtain a copy of the License at
60
+
61
+ http://www.apache.org/licenses/LICENSE-2.0
62
+
63
+ Unless required by applicable law or agreed to in writing, software
64
+ distributed under the License is distributed on an "AS IS" BASIS,
65
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
66
+ See the License for the specific language governing permissions and
67
+ limitations under the License.
data/hoy/Procfile ADDED
@@ -0,0 +1,2 @@
1
+ web: bundle exec puma -p $PORT -e production
2
+ redis: redis-server
data/hoy/Procfile.dev ADDED
@@ -0,0 +1,2 @@
1
+ web: bundle exec puma -p 3000 -e development
2
+ redis: redis-server
data/hoy/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # SOULs Ruby GraphQL API Server
2
+ SOULs Ruby GraphQL API Server 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
+ ## Installation
13
+
14
+ git clone
15
+
16
+ ```
17
+ git clone git@github.com:elsoul/souls_api.git
18
+ cd souls_api
19
+ bundle install
20
+ ```
21
+
22
+
23
+ # Run Server on local
24
+
25
+ ```ruby
26
+ souls s
27
+ ```
28
+
29
+
30
+ ## SOULs Document
31
+
32
+ - [SOULs Document](https://souls-doc.el-soul.com/)
33
+
34
+
35
+
36
+
37
+ You can see GraphQL Playground here;
38
+
39
+ `localhost:3000/playground`
40
+
41
+
42
+
43
+
44
+
45
+ ## Development
46
+
47
+ 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.
48
+
49
+ 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_api).
50
+
51
+ ## Contributing
52
+
53
+ 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.
54
+
55
+ ## License
56
+
57
+ The gem is available as open source under the terms of the [Apache-2.0 License](https://www.apache.org/licenses/LICENSE-2.0).
58
+
59
+ ## Code of Conduct
60
+
61
+ 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_api/blob/master/CODE_OF_CONDUCT.md).
data/hoy/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "./app"
2
+ require "sinatra/activerecord/rake"
3
+ require "graphql/rake_task"
4
+
5
+ GraphQL::RakeTask.new(schema_name: "SoulsApiSchema")
data/hoy/app.rb ADDED
@@ -0,0 +1,116 @@
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 "psych"
10
+ require "sinatra/activerecord"
11
+ require "rack/contrib"
12
+ require "zeitwerk"
13
+ require "factory_bot"
14
+ require "faker"
15
+ require "dotenv/load"
16
+ require "firebase_id_token"
17
+ require "graphql"
18
+ require "google/cloud/firestore"
19
+ require "google/cloud/storage"
20
+ require "google/cloud/pubsub"
21
+ require "logger"
22
+ require "base64"
23
+ require "slack/ruby3"
24
+ require "role_model"
25
+ require "pundit"
26
+ require "sendgrid-ruby"
27
+ require "search_object"
28
+ require "search_object/plugin/graphql"
29
+ require "graphql/batch"
30
+
31
+ ENV["RACK_ENV"] ||= "development"
32
+ Dir["./config/*.rb"].each { |f| require f unless f.include?("souls.rb") }
33
+ Dir["./constants/*.rb"].each { |f| require f }
34
+
35
+ db_conf = YAML.safe_load(ERB.new(File.read("./config/database.yml")).result, permitted_classes: [Date], aliases: true)
36
+ ActiveRecord::Base.establish_connection(db_conf[ENV["RACK_ENV"]])
37
+ ActiveRecord::Base.default_timezone = :local
38
+
39
+ loader = Zeitwerk::Loader.new
40
+ loader.push_dir("#{Dir.pwd}/app/models")
41
+ loader.push_dir("#{Dir.pwd}/app/utils")
42
+ loader.push_dir("#{Dir.pwd}/app/policies")
43
+
44
+ loader.do_not_eager_load("#{Dir.pwd}/app/services")
45
+ loader.collapse("#{__dir__}/app/types")
46
+ loader.collapse("#{__dir__}/app/mutations")
47
+ loader.collapse("#{__dir__}/app/queries")
48
+ loader.collapse("#{__dir__}/app/services")
49
+ loader.collapse("#{__dir__}/app/resolvers")
50
+ loader.collapse("#{__dir__}/app/graphql/types/connections")
51
+ loader.collapse("#{__dir__}/app/graphql/types/edges")
52
+ loader.collapse("#{__dir__}/app/graphql/types/base")
53
+ loader.push_dir("#{Dir.pwd}/app/graphql")
54
+ loader.setup
55
+
56
+ class SoulsApi < Sinatra::Base
57
+ include Pundit
58
+ include SoulsHelper
59
+ ::Logger.class_eval { alias_method :write, :<< }
60
+ access_log = ::File.join(::File.dirname(::File.expand_path(__FILE__)), "log", "access.log")
61
+ access_logger = ::Logger.new(access_log)
62
+ error_logger = ::File.new(::File.join(::File.dirname(::File.expand_path(__FILE__)), "log", "error.log"), "a+")
63
+ error_logger.sync = true
64
+
65
+ use Rack::JSONBodyParser
66
+ register Sinatra::ActiveRecordExtension
67
+
68
+ configure :production, :development do
69
+ set :logger, Logger.new($stdout)
70
+ enable :logging
71
+ use ::Rack::CommonLogger, access_logger
72
+ end
73
+
74
+ before { env["rack.errors"] = error_logger }
75
+
76
+ error StandardError do
77
+ StandardError.to_json
78
+ end
79
+
80
+ get "/" do
81
+ message = { success: true, message: "SOULs Running!", env: ENV["RACK_ENV"] }
82
+ json message
83
+ end
84
+
85
+ get "/db" do
86
+ message = { success: true, message: "SOULs Running!", env: ENV["RACK_ENV"], db: User.first.username }
87
+ json(message)
88
+ rescue StandardError => e
89
+ message = { error: e }
90
+ json(message)
91
+ end
92
+
93
+ post "/endpoint" do
94
+ token = request.env["HTTP_AUTHORIZATION"].split("Bearer ")[1] if request.env["HTTP_AUTHORIZATION"]
95
+
96
+ user = token ? login_auth(token: token) : nil
97
+ context = { user: user }
98
+ result = SoulsApiSchema.execute(params[:query], variables: params[:variables], context: context)
99
+ json(result)
100
+ rescue StandardError => e
101
+ message = { error: e }
102
+ json(message)
103
+ end
104
+
105
+ def login_auth(token:)
106
+ decoded_token = JsonWebToken.decode(token)
107
+ user_id = decoded_token[:user_id]
108
+ user = User.find(user_id)
109
+ raise(StandardError, "Invalid or Missing Token") if user.blank?
110
+
111
+ user
112
+ rescue StandardError => e
113
+ message = { error: e }
114
+ json(message)
115
+ end
116
+ 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