Class: Mutations::Auth::UpdateAccount
- Inherits:
-
GraphQL::Schema::Mutation
- Object
- GraphQL::Schema::Mutation
- Mutations::Auth::UpdateAccount
- Defined in:
- app/graphql/mutations/auth/update_account.rb
Overview
mutation {
updateAccount(current_password: "currentPassword", password: "newPassword", password_confirmation: "newPassword") {
success
user {
email
}
errors {
field
}
}
}
Instance Method Summary collapse
Instance Method Details
#resolve(args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/graphql/mutations/auth/update_account.rb', line 33 def resolve(args) user = context[:current_user] user.update_with_password args if user.errors.any? { errors: user.errors..map do |field, | { field: field.to_s.camelize(:lower), message: .first.capitalize } end, success: false, user: nil } else { errors: [], success: true, user: user } end end |