Skip to content

Instantly share code, notes, and snippets.

@mekhami
Created March 28, 2018 19:03
Show Gist options
  • Save mekhami/1b4d9b4b67e2110c5bccf2e73d407a3d to your computer and use it in GitHub Desktop.
Save mekhami/1b4d9b4b67e2110c5bccf2e73d407a3d to your computer and use it in GitHub Desktop.
def mutate(root, info, **args):
try:
item = inventory_api.get_item(
args['item'],
session=info.context['session'],
agent=info.context['user'])
if args['method'].lower() == 'remove':
item_qty_adjustment = item.remove_qty(args['qty'])
elif args['method'].lower() == 'add':
item_qty_adjustment =item.add_qty(args['qty'])
info.context['session'].commit()
ok = True
error = None
except Exception as e:
item = None
item_qty_adjustment = None
ok = False
error = e
return CreateItemQtyAdjustment(
item=item,
item_qty_adjustment=item_qty_adjustment,
ok=ok,
error=error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment