Skip to content

Commit

Permalink
Add targetUser to Types::Post (#1341)
Browse files Browse the repository at this point in the history
* Add `targetUser` to Types::Post

* Add `target_user_id` to Post::Create input

* Rename targetUser to targetProfile
  • Loading branch information
shomykohai authored Nov 12, 2023
1 parent fba65ac commit c089adb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/graphql/types/input/post/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Types::Input::Post::Create < Types::Input::Base
argument :is_nsfw, Boolean, required: false, default_value: false, as: :nsfw
argument :spoiled_unit_id, ID, required: false
argument :spoiled_unit_type, String, required: false
argument :target_user_id, ID, required: false

def to_model
to_h.merge({ user_id: current_user&.id })
Expand Down
8 changes: 8 additions & 0 deletions app/graphql/types/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,12 @@ def follows
Loaders::RecordLoader.for(User, token: context[:token]).load_many(follows.pluck(:user_id))
end
end

field :target_profile, Types::Profile,
null: false,
description: 'The profile of the target user of the post.'

def target_profile
Loaders::RecordLoader.for(User).load(object.target_user_id)
end
end

0 comments on commit c089adb

Please sign in to comment.