Creating a Storefront App
This guide covers a series of queries and mutations to handle typical storefront application scenarios.
Fetching products
const projectAccessToken = '<Your-project-access-token>'
const headers = new Headers({
'Content-Type': 'application/json',
'X-Project-Access-Token': projectAccessToken
})
const graphql = JSON.stringify({
query: `query products($after: String, $first: Int){
products(after: $after, first: $first) {
totalCount
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
nodes {
available
eligibleForDiscount
graceCancellationEnabled
graceCancellationPeriod
graceCancellationUnit
id
imageUrl
interval
intervalUnitOfMeasure
mandatory
maximumCommitmentEnabled
maximumCommitmentPeriod
maximumCommitmentUnit
metadata
minimumCommitmentEnabled
minimumCommitmentPeriod
minimumCommitmentUnit
nthProductFree
priceCents
priceExcludingTaxCents
priceWithSymbol
productType
shopifyProductId
shopifyVariantId
sku
slug
supplier
taxAmountCents
taxPercentage
title
}
}
}
`,
variables: {
after: null,
first: 10
}
})
const requestOptions = {
method: 'POST',
headers,
body: graphql,
};
const response = await fetch("https://portal.firmhouse.com/graphql", requestOptions)
const data = await response.json()
const {totalCount, nodes: products, pageInfo} = data.data.products
Fetching Plans
Creating a cart
Adding products to the cart
Removing products from the cart
Updating the quantities of products in the cart
Updating the subscription plan
Fetching current cart information
Updating address details
Generating payment links
Last updated
Was this helpful?