Skip to content

Commit

Permalink
Merge pull request #1351 from safewlabs/delete-user-mutation
Browse files Browse the repository at this point in the history
Add delete user mutation
  • Loading branch information
saurabhbhatia authored Sep 19, 2024
2 parents e88becb + 4c0aabc commit d0bc71a
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 30 deletions.
42 changes: 21 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GIT

GIT
remote: https://github.com/faker-ruby/faker.git
revision: caa55073c3217c65c4929c49d48cf5b0617d5fb6
revision: 6ba06393f47d4018b5fdbdaaa04eb9891ae5fb55
branch: main
specs:
faker (3.4.2)
Expand Down Expand Up @@ -96,17 +96,17 @@ GEM
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
aws-eventstream (1.3.0)
aws-partitions (1.971.0)
aws-sdk-core (3.203.0)
aws-partitions (1.976.0)
aws-sdk-core (3.205.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.89.0)
aws-sdk-core (~> 3, >= 3.203.0)
aws-sdk-kms (1.91.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.160.0)
aws-sdk-core (~> 3, >= 3.203.0)
aws-sdk-s3 (1.162.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.9.1)
Expand Down Expand Up @@ -178,7 +178,7 @@ GEM
activesupport (>= 6.1)
graphiql-rails (1.10.1)
railties
graphql (2.3.14)
graphql (2.3.16)
base64
fiber-storage
graphql_devise (1.5.0)
Expand All @@ -192,7 +192,7 @@ GEM
csv
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
i18n (1.14.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
image_processing (1.13.0)
mini_magick (>= 4.9.5, < 5)
Expand All @@ -203,7 +203,7 @@ GEM
irb (1.14.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jbuilder (2.12.0)
jbuilder (2.13.0)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
jmespath (1.6.2)
Expand Down Expand Up @@ -261,7 +261,7 @@ GEM
rack (>= 2.2.3)
rack-protection
orm_adapter (0.5.0)
pagy (9.0.8)
pagy (9.0.9)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
Expand All @@ -270,7 +270,7 @@ GEM
pg_search (2.3.7)
activerecord (>= 6.1)
activesupport (>= 6.1)
propshaft (0.9.1)
propshaft (1.0.0)
actionpack (>= 7.0.0)
activesupport (>= 7.0.0)
rack
Expand Down Expand Up @@ -346,7 +346,7 @@ GEM
rolify (6.0.1)
rspec-core (3.13.1)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.2)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
Expand All @@ -373,17 +373,17 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
rubocop-md (1.2.2)
rubocop (>= 1.0)
rubocop-md (1.2.3)
rubocop (>= 1.45)
rubocop-minitest (0.36.0)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-packaging (0.5.2)
rubocop (>= 1.33, < 2.0)
rubocop-performance (1.21.1)
rubocop-performance (1.22.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.26.0)
rubocop-rails (2.26.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.52.0, < 2.0)
Expand All @@ -396,7 +396,7 @@ GEM
rubocop-packaging (~> 0.5)
rubocop-performance (~> 1.11)
rubocop-rails (~> 2.0)
rubocop-rspec (3.0.4)
rubocop-rspec (3.0.5)
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
ruby-vips (2.2.2)
Expand All @@ -419,16 +419,16 @@ GEM
stimulus-rails (1.3.4)
railties (>= 6.0.0)
stringio (3.1.1)
stripe (12.5.0)
stripe (12.6.0)
thor (1.3.2)
timeout (0.4.1)
turbo-rails (2.0.6)
turbo-rails (2.0.7)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
unicode-display_width (2.6.0)
view_component (3.14.0)
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
Expand Down
9 changes: 9 additions & 0 deletions app/graphql/types/mutation_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ class MutationType < Types::BaseObject
field_class GraphqlDevise::Types::BaseField
field :test_field, String, null: false,
description: "An example field added by the generator"
field :mark_user_for_deletion, String, null: false, description: "Delete and Logout a user" do
argument :user_id, ID, required: true
end
def test_field
"Hello World"
end

def mark_user_for_deletion(params)
user_id = params[:user_id].to_i
user = User.find(user_id)
user.update(mark_for_deletion: true)
end
end
end
2 changes: 1 addition & 1 deletion app/models/creator_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ class CreatorProfile < ApplicationRecord
foreign_key: :user_id,
through: :creator_profiles_managers

has_many :collaborations
has_many :collaborations, dependent: :destroy
has_many :products, through: :collaborations
end
14 changes: 7 additions & 7 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# last_name :string
# last_sign_in_at :datetime
# last_sign_in_ip :string
# mark_for_deletion :boolean
# provider :string
# publishable_key :string
# remember_created_at :datetime
Expand Down Expand Up @@ -45,20 +46,19 @@ class User < ApplicationRecord
:confirmable, :omniauthable
include GraphqlDevise::Authenticatable
rolify
has_many :projects
has_one :store
has_one :creator_profile
has_one_attached :avatar
has_one :store, dependent: :destroy
has_one :creator_profile, dependent: :destroy
has_one_attached :avatar, dependent: :destroy
has_many :backings, dependent: :destroy
has_many :projects, through: :backings
has_many :projects, through: :backings, dependent: :destroy
has_many :creator_profiles_managers, dependent: :destroy
has_many :managed_profiles,
class_name: "CreatorProfile",
foreign_key: :creator_profile_id,
through: :creator_profiles_managers
through: :creator_profiles_managers, dependent: :destroy
has_many :purchases, dependent: :destroy
has_many :products, through: :purchases
has_many :orders
has_many :orders, dependent: :destroy
# validates :first_name, :last_name, :email, :password, presence: true
# validates_confirmation_of :password
before_validation :set_uid_provider
Expand Down
7 changes: 7 additions & 0 deletions db/migrate/20240919114023_add_mark_for_deletion_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class AddMarkForDeletionToUsers < ActiveRecord::Migration[7.1]
def change
add_column :users, :mark_for_deletion, :boolean
end
end
3 changes: 2 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# last_name :string
# last_sign_in_at :datetime
# last_sign_in_ip :string
# mark_for_deletion :boolean
# provider :string
# publishable_key :string
# remember_created_at :datetime
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# last_name :string
# last_sign_in_at :datetime
# last_sign_in_ip :string
# mark_for_deletion :boolean
# provider :string
# publishable_key :string
# remember_created_at :datetime
Expand Down
1 change: 1 addition & 0 deletions test/models/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# last_name :string
# last_sign_in_at :datetime
# last_sign_in_ip :string
# mark_for_deletion :boolean
# provider :string
# publishable_key :string
# remember_created_at :datetime
Expand Down

0 comments on commit d0bc71a

Please sign in to comment.