AbiirSkincare/Hydrogen/web/app/graphql/customer-account/AccountOverviewQuery.ts

59 lines
1.3 KiB
TypeScript

// Dashboard stats + most recent order for /account
// Fragment strings must be concatenated only once in ACCOUNT_OVERVIEW_QUERY
// to avoid "Fragment name must be unique" in a single request document.
const ACCOUNT_OVERVIEW_MONEY = `#graphql
fragment AccountOverviewMoney on MoneyV2 {
amount
currencyCode
}
` as const;
const ACCOUNT_OVERVIEW_LINE = `#graphql
fragment AccountOverviewLine on LineItem {
title
quantity
price {
...AccountOverviewMoney
}
}
` as const;
const ACCOUNT_OVERVIEW_ORDER = `#graphql
fragment AccountOverviewOrder on Order {
id
name
confirmationNumber
processedAt
fulfillmentStatus
totalPrice {
...AccountOverviewMoney
}
lineItems(first: 6) {
nodes {
...AccountOverviewLine
}
}
}
` as const;
export const ACCOUNT_OVERVIEW_QUERY = `#graphql
query AccountOverview($language: LanguageCode)
@inContext(language: $language) {
customer {
creationDate
orders(first: 100, sortKey: PROCESSED_AT, reverse: true) {
pageInfo {
hasNextPage
}
nodes {
...AccountOverviewOrder
}
}
}
}
${ACCOUNT_OVERVIEW_MONEY}
${ACCOUNT_OVERVIEW_LINE}
${ACCOUNT_OVERVIEW_ORDER}
` as const;