Skip to content

Instantly share code, notes, and snippets.

@jneurock
Created October 11, 2018 13:26
Show Gist options
  • Save jneurock/67901a119b9e2fbe55734d858e15e894 to your computer and use it in GitHub Desktop.
Save jneurock/67901a119b9e2fbe55734d858e15e894 to your computer and use it in GitHub Desktop.
Update Cart Items GraphQL Example
import Controller from '@ember/controller';
import updateCartItems from 'my-app/gql/mutations/update-cart-items';
export default Controller.extend({
actions: {
updateCartItemsAddress(cartId, address) {
this.get('apollo').mutate({
mutation: updateCartItems,
variables: { cartId,
attrs: { address }
}
}).catch(() => {
// Now a bit easier to deal with
});
}
}
});
#import 'my-app/gql/fragments/cart-item'
mutation($cartId: ID!, $attrs: CartItemInput!) {
updateCartItems(cartId: $cartId, attrs: $attrs) {
...cartItem
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment