Examples

This section provides examples of using GraphQL to work with a variety of different types including shops, products, and customers.

For complete reference information, see the GraphQL Admin API reference.

Get basic shop info and the product handle of the first three products


{
  shop {
    id
    name
  }
  products(first: 3) {
    edges {
      node {
        handle
      }
    }
  }
}

Create a new product and return the name and primary domain of the shop

mutation {
  productCreate(input: {title: "Sweet new product", productType: "Snowboard", vendor: "JadedPixel"}) {
    product {
      id
    }
    shop {
      name
      primaryDomain
    }
  }
}

Update a product

mutation {
  productUpdate(input: {id: "gid://shopify/Product/629116370966", title: "Sweet new product - GraphQL Edition"} ) {
    product {
      id
    }
  }
}

Update customer details

mutation {
  customerUpdate(input: {id: "gid://shopify/Customer/491279155222", firstName: "Supersample GraphQL"}) {
    userErrors {
      field
      message
    }
    customer {
      id
    }
  }
}