Created
March 28, 2018 19:03
-
-
Save mekhami/1b4d9b4b67e2110c5bccf2e73d407a3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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