Class: SolidusGraphqlApi::Mutations::User::SaveInAddressBook

Inherits:
BaseMutation
  • Object
show all
Defined in:
lib/solidus_graphql_api/mutations/user/save_in_address_book.rb

Defined Under Namespace

Classes: AddressTypeInput

Instance Method Summary collapse

Instance Method Details

#ready?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/solidus_graphql_api/mutations/user/save_in_address_book.rb', line 30

def ready?(*)
  current_ability.authorize!(:save_in_address_book, current_user)
end

#resolve(address:, address_type:, default: false) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/solidus_graphql_api/mutations/user/save_in_address_book.rb', line 21

def resolve(address:, address_type:, default: false)
  address = current_user.save_in_address_book(address, default, address_type.to_sym)

  {
    user: current_user,
    errors: user_errors("address", address.errors)
  }
end