Rename GraphQL fields with aliases

23 Aug 2021

{
  cart(id: "my-cart-id") {
    count: totalItems
    products: items {
      title: name
      created: createdAt
    }
  }

  cart2: cart(id: "abc") {
    id
    totalItems
  }
}
mutation {
  addToCart: addItem(
    input: {
      cartId: "my-cart-id"
      id: "my-item-id"
      name: "GraphQL Stickers"
      price: 1000
    }
  ) {
    id
    items {
      title: name
      lineTotal {
        amount
        formatted
      }
    }
  }
}