Class: SolidusGraphqlApi::Mutations::User::MarkDefaultShipAddress

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

Instance Method Summary collapse

Instance Method Details

#authorized?(address:) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/solidus_graphql_api/mutations/user/mark_default_ship_address.rb', line 25

def authorized?(address:)
  current_user.user_addresses.find_by!(address_id: address.id)
end

#ready?Boolean

Returns:

  • (Boolean)

Raises:

  • (CanCan::AccessDenied)


19
20
21
22
23
# File 'lib/solidus_graphql_api/mutations/user/mark_default_ship_address.rb', line 19

def ready?(*)
  return true if current_user.present?

  raise CanCan::AccessDenied
end

#resolve(address:) ⇒ Object



13
14
15
16
17
# File 'lib/solidus_graphql_api/mutations/user/mark_default_ship_address.rb', line 13

def resolve(address:)
  current_user.mark_default_ship_address(address)

  { user: current_user.reload }
end