Variant Prices

Using the GraphQL Storefront API, you can now request the prices of variants in addition to products.

Consider the query below:

query {
  site {
    products(first: 3) {
      edges {
        node {
          prices {
            ...PricesFields
          }
          name
          variants(first:4) {
            edges {
              node {
                sku
                prices {
                  ...PricesFields
                }
              }
            }
          }
        }
      }
    }
  }
}

fragment PricesFields on Prices {
  price {
    ...PriceFields
  }
  salePrice {
    ...PriceFields
  }
  retailPrice {
    ...PriceFields
  }
}

fragment PriceFields on Money {
  value
  currencyCode
}

Customer Login

If you’re using the Storefront API from a browser (for example, on top of your Stencil storefront) you can use the new Customer Login mutation to log in a customer account with an email address and password. (For server-side integrations, consider a customer impersonation token instead)

This will set a session cookie in the browser which will authenticate the customer account on future requests.

The mutation looks like this:

mutation Login($email: String!, $pass: String!) {
  login(email: $email, password: $pass) {
    result
  }
}

As a best practice, you should inject the password using a GraphQL query variables. This prevents the password from being exposed in the query itself.

In GraphQL Playground, you can set the variables for the request:

sa0WHTU.png