Skip to content

Commit

Permalink
Add Update Preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
abshierjoel committed Oct 4, 2021
1 parent 796e50c commit 0a97835
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/gql_preferences_web/resolvers/preferences.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
defmodule UserPreferencesWeb.Resolvers.Preferences do
alias UserPreferences.{Repo, Preferences}

def get_preferences(parent, _args, _) do
Preferences
|> Repo.get_by(user_id: parent.id)
|> then(&{:ok, &1})
end

def update_preferences_by_id(_, args, _) do
Repo.get_by(Preferences, user_id: args.user_id)
|> Preferences.changeset(args)
|> Repo.update()
end
end

0 comments on commit 0a97835

Please sign in to comment.