Class: SolidusGraphqlApi::Mutations::Checkout::AddToCart

Inherits:
BaseMutation
  • Object
show all
Defined in:
lib/solidus_graphql_api/mutations/checkout/add_to_cart.rb

Instance Method Summary collapse

Instance Method Details

#ready?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/solidus_graphql_api/mutations/checkout/add_to_cart.rb', line 24

def ready?(*)
  current_ability.authorize!(:update, current_order, guest_token)
end

#resolve(variant:, quantity:) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/solidus_graphql_api/mutations/checkout/add_to_cart.rb', line 15

def resolve(variant:, quantity:)
  line_item = current_order.contents.add(variant, quantity)

  {
    order: current_order,
    errors: user_errors("line_item", line_item.errors)
  }
end