Merge branch 'addGraphQLCodegen' of https://github.com/cond0r/commerce into shopify-updates

This commit is contained in:
cond0r 2021-05-24 08:30:11 +03:00
commit 03ad9ba902
24 changed files with 1082 additions and 354 deletions

View File

@ -121,3 +121,15 @@ const pages = await getAllPages({
config, config,
}) })
``` ```
## Code generation
This provider makes use of GraphQL code generation. The [schema.graphql](./schema.graphql) and [schema.d.ts](./schema.d.ts) files contain the generated types & schema introspection results.
When developing the provider, changes to any GraphQL operations should be followed by re-generation of the types and schema files:
From the project root dir, run:
```sh
yarn generate:shopify
```

View File

@ -1,6 +1,12 @@
import { ProductEdge } from '../../schema' import {
GetAllProductPathsQuery,
GetAllProductVendorsQuery,
ProductEdge,
} from '../../schema'
import { ShopifyConfig } from '..' import { ShopifyConfig } from '..'
type FetchAllProductsQuery = GetAllProductPathsQuery | GetAllProductVendorsQuery
const fetchAllProducts = async ({ const fetchAllProducts = async ({
config, config,
query, query,
@ -10,19 +16,18 @@ const fetchAllProducts = async ({
}: { }: {
config: ShopifyConfig config: ShopifyConfig
query: string query: string
acc?: ProductEdge[] acc?: any[]
variables?: any variables?: any
cursor?: string cursor?: string
}): Promise<ProductEdge[]> => { }): Promise<ProductEdge[]> => {
const { data } = await config.fetch(query, { const { data } = await config.fetch<FetchAllProductsQuery>(query, {
variables: { ...variables, cursor }, variables: { ...variables, cursor },
}) })
const edges: ProductEdge[] = data.products?.edges ?? [] const edges = data.products.edges
const hasNextPage = data.products?.pageInfo?.hasNextPage
acc = acc.concat(edges) acc = acc.concat(edges)
if (hasNextPage) { if (data.products.pageInfo.hasNextPage) {
const cursor = edges.pop()?.cursor const cursor = edges.pop()?.cursor
if (cursor) { if (cursor) {
return fetchAllProducts({ return fetchAllProducts({

View File

@ -0,0 +1,32 @@
{
"schema": {
"https://${NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN}/api/2021-01/graphql.json": {
"headers": {
"X-Shopify-Storefront-Access-Token": "${NEXT_PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN}"
}
}
},
"documents": [
{
"./framework/shopify/**/*.{ts,tsx}": {
"noRequire": true
}
}
],
"generates": {
"./framework/shopify/schema.d.ts": {
"plugins": ["typescript", "typescript-operations"],
"config": {
"scalars": {
"ID": "string"
}
}
},
"./framework/shopify/schema.graphql": {
"plugins": ["schema-ast"]
}
},
"hooks": {
"afterAllFileWrite": ["prettier --write"]
}
}

View File

@ -1,6 +1,7 @@
import { getConfig, ShopifyConfig } from '../api' import { getConfig, ShopifyConfig } from '../api'
import getCustomerIdQuery from '../utils/queries/get-customer-id-query' import getCustomerIdQuery from '../utils/queries/get-customer-id-query'
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import { GetCustomerIdQuery } from '../schema'
async function getCustomerId({ async function getCustomerId({
customerToken: customerAccesToken, customerToken: customerAccesToken,
@ -8,17 +9,19 @@ async function getCustomerId({
}: { }: {
customerToken: string customerToken: string
config?: ShopifyConfig config?: ShopifyConfig
}): Promise<number | undefined> { }): Promise<string | undefined> {
config = getConfig(config) config = getConfig(config)
const { data } = await config.fetch(getCustomerIdQuery, { const {
data: { customer },
} = await config.fetch<GetCustomerIdQuery>(getCustomerIdQuery, {
variables: { variables: {
customerAccesToken: customerAccesToken:
customerAccesToken || Cookies.get(config.customerCookie), customerAccesToken || Cookies.get(config.customerCookie),
}, },
}) })
return data.customer?.id return customer?.id
} }
export default getCustomerId export default getCustomerId

View File

@ -10,11 +10,15 @@ export const handler: SWRHook<Customer | null> = {
query: getCustomerQuery, query: getCustomerQuery,
}, },
async fetcher({ options, fetch }) { async fetcher({ options, fetch }) {
const data = await fetch<any | null>({ const customerAccessToken = getCustomerToken()
if (customerAccessToken) {
const data = await fetch({
...options, ...options,
variables: { customerAccessToken: getCustomerToken() }, variables: { customerAccessToken: getCustomerToken() },
}) })
return data.customer ?? null return data.customer
}
return null
}, },
useHook: ({ useData }) => (input) => { useHook: ({ useData }) => (input) => {
return useData({ return useData({

View File

@ -1,4 +1,4 @@
import { CollectionEdge } from '../schema' import { GetSiteCollectionsQuery } from '../schema'
import { getConfig, ShopifyConfig } from '../api' import { getConfig, ShopifyConfig } from '../api'
import getAllCollectionsQuery from '../utils/queries/get-all-collections-query' import getAllCollectionsQuery from '../utils/queries/get-all-collections-query'
@ -10,11 +10,13 @@ const getAllCollections = async (options?: {
let { config, variables = { first: 250 } } = options ?? {} let { config, variables = { first: 250 } } = options ?? {}
config = getConfig(config) config = getConfig(config)
const { data } = await config.fetch(getAllCollectionsQuery, { variables }) const { data } = await config.fetch<GetSiteCollectionsQuery>(
const edges = data.collections?.edges ?? [] getAllCollectionsQuery,
{ variables }
)
const categories = edges.map( const categories = data.collections.edges.map(
({ node: { id: entityId, title: name, handle } }: CollectionEdge) => ({ ({ node: { id: entityId, title: name, handle } }) => ({
entityId, entityId,
name, name,
path: `/${handle}`, path: `/${handle}`,

View File

@ -1,7 +1,5 @@
import { Product } from '@commerce/types'
import { getConfig, ShopifyConfig } from '../api' import { getConfig, ShopifyConfig } from '../api'
import fetchAllProducts from '../api/utils/fetch-all-products' import fetchAllProducts from '../api/utils/fetch-all-products'
import { ProductEdge } from '../schema'
import getAllProductsPathsQuery from '../utils/queries/get-all-products-paths-query' import getAllProductsPathsQuery from '../utils/queries/get-all-products-paths-query'
type ProductPath = { type ProductPath = {
@ -31,7 +29,7 @@ const getAllProductPaths = async (options?: {
}) })
return { return {
products: products?.map(({ node: { handle } }: ProductEdge) => ({ products: products?.map(({ node: { handle } }) => ({
node: { node: {
path: `/${handle}`, path: `/${handle}`,
}, },

View File

@ -1,6 +1,5 @@
import { GraphQLFetcherResult } from '@commerce/api'
import { getConfig, ShopifyConfig } from '../api' import { getConfig, ShopifyConfig } from '../api'
import { ProductEdge } from '../schema' import { GetAllProductsQuery, Product as ShopifyProduct } from '../schema'
import { getAllProductsQuery } from '../utils/queries' import { getAllProductsQuery } from '../utils/queries'
import { normalizeProduct } from '../utils/normalize' import { normalizeProduct } from '../utils/normalize'
import { Product } from '@commerce/types' import { Product } from '@commerce/types'
@ -10,30 +9,25 @@ type Variables = {
field?: string field?: string
} }
type ReturnType = {
products: Product[]
}
const getAllProducts = async (options: { const getAllProducts = async (options: {
variables?: Variables variables?: Variables
config?: ShopifyConfig config?: ShopifyConfig
preview?: boolean preview?: boolean
}): Promise<ReturnType> => { }): Promise<{
products: Product[]
}> => {
let { config, variables = { first: 250 } } = options ?? {} let { config, variables = { first: 250 } } = options ?? {}
config = getConfig(config) config = getConfig(config)
const { data }: GraphQLFetcherResult = await config.fetch( const { data } = await config.fetch<GetAllProductsQuery>(
getAllProductsQuery, getAllProductsQuery,
{ variables } { variables }
) )
const products =
data.products?.edges?.map(({ node: p }: ProductEdge) =>
normalizeProduct(p)
) ?? []
return { return {
products, products: data.products.edges.map(({ node }) =>
normalizeProduct(node as ShopifyProduct)
),
} }
} }

View File

@ -1,30 +1,32 @@
import { GraphQLFetcherResult } from '@commerce/api' import { GetProductBySlugQuery, Product as ShopifyProduct } from '../schema'
import { getConfig, ShopifyConfig } from '../api' import { getConfig, ShopifyConfig } from '../api'
import { normalizeProduct, getProductQuery } from '../utils' import { normalizeProduct, getProductQuery } from '../utils'
import { Product } from '@commerce/types'
type Variables = { type Variables = {
slug: string slug: string
} }
type ReturnType = {
product: any
}
const getProduct = async (options: { const getProduct = async (options: {
variables: Variables variables: Variables
config: ShopifyConfig config: ShopifyConfig
preview?: boolean preview?: boolean
}): Promise<ReturnType> => { }): Promise<{
product?: Product
}> => {
let { config, variables } = options ?? {} let { config, variables } = options ?? {}
config = getConfig(config) config = getConfig(config)
const { data }: GraphQLFetcherResult = await config.fetch(getProductQuery, { const {
data: { productByHandle },
} = await config.fetch<GetProductBySlugQuery>(getProductQuery, {
variables, variables,
}) })
const { productByHandle } = data
return { return {
product: productByHandle ? normalizeProduct(productByHandle) : null, ...(productByHandle && {
product: normalizeProduct(productByHandle as ShopifyProduct),
}),
} }
} }

View File

@ -1,7 +1,12 @@
import { SWRHook } from '@commerce/utils/types' import { SWRHook } from '@commerce/utils/types'
import useSearch, { UseSearch } from '@commerce/product/use-search' import useSearch, { UseSearch } from '@commerce/product/use-search'
import { ProductEdge } from '../schema' import {
CollectionEdge,
GetAllProductsQuery,
Product as ShopifyProduct,
ProductEdge,
} from '../schema'
import { import {
getAllProductsQuery, getAllProductsQuery,
getCollectionProductsQuery, getCollectionProductsQuery,
@ -35,30 +40,38 @@ export const handler: SWRHook<
}, },
async fetcher({ input, options, fetch }) { async fetcher({ input, options, fetch }) {
const { categoryId, brandId } = input const { categoryId, brandId } = input
const method = options?.method
const variables = getSearchVariables(input)
let products
const data = await fetch({ // change the query to getCollectionProductsQuery when categoryId is set
query: categoryId ? getCollectionProductsQuery : options.query,
method: options?.method,
variables: getSearchVariables(input),
})
let edges
if (categoryId) { if (categoryId) {
edges = data.node?.products?.edges ?? [] const data = await fetch<CollectionEdge>({
if (brandId) { query: getCollectionProductsQuery,
edges = edges.filter( method,
variables,
})
// filter on client when brandId & categoryId are set since is not available on collection product query
products = brandId
? data.node.products.edges.filter(
({ node: { vendor } }: ProductEdge) => ({ node: { vendor } }: ProductEdge) =>
vendor.replace(/\s+/g, '-').toLowerCase() === brandId vendor.replace(/\s+/g, '-').toLowerCase() === brandId
) )
} : data.node.products.edges
} else { } else {
edges = data.products?.edges ?? [] const data = await fetch<GetAllProductsQuery>({
query: options.query,
method,
variables,
})
products = data.products.edges
} }
return { return {
products: edges.map(({ node }: ProductEdge) => normalizeProduct(node)), products: products?.map(({ node }) =>
found: !!edges.length, normalizeProduct(node as ShopifyProduct)
),
found: !!products?.length,
} }
}, },
useHook: ({ useData }) => (input = {}) => { useHook: ({ useData }) => (input = {}) => {

View File

@ -37,7 +37,7 @@ export type ApiVersion = {
displayName: Scalars['String'] displayName: Scalars['String']
/** The unique identifier of an ApiVersion. All supported API versions have a date-based (YYYY-MM) or `unstable` handle. */ /** The unique identifier of an ApiVersion. All supported API versions have a date-based (YYYY-MM) or `unstable` handle. */
handle: Scalars['String'] handle: Scalars['String']
/** Whether the version is supported by Shopify. */ /** Whether the version is actively supported by Shopify. Supported API versions are guaranteed to be stable. Unsupported API versions include unstable, release candidate, and end-of-life versions that are marked as unsupported. For more information, refer to [Versioning](https://shopify.dev/concepts/about-apis/versioning). */
supported: Scalars['Boolean'] supported: Scalars['Boolean']
} }
@ -306,17 +306,17 @@ export enum BlogSortKeys {
/** Card brand, such as Visa or Mastercard, which can be used for payments. */ /** Card brand, such as Visa or Mastercard, which can be used for payments. */
export enum CardBrand { export enum CardBrand {
/** Visa */ /** Visa. */
Visa = 'VISA', Visa = 'VISA',
/** Mastercard */ /** Mastercard. */
Mastercard = 'MASTERCARD', Mastercard = 'MASTERCARD',
/** Discover */ /** Discover. */
Discover = 'DISCOVER', Discover = 'DISCOVER',
/** American Express */ /** American Express. */
AmericanExpress = 'AMERICAN_EXPRESS', AmericanExpress = 'AMERICAN_EXPRESS',
/** Diners Club */ /** Diners Club. */
DinersClub = 'DINERS_CLUB', DinersClub = 'DINERS_CLUB',
/** JCB */ /** JCB. */
Jcb = 'JCB', Jcb = 'JCB',
} }
@ -1195,6 +1195,8 @@ export enum CountryCode {
Am = 'AM', Am = 'AM',
/** Aruba. */ /** Aruba. */
Aw = 'AW', Aw = 'AW',
/** Ascension Island. */
Ac = 'AC',
/** Australia. */ /** Australia. */
Au = 'AU', Au = 'AU',
/** Austria. */ /** Austria. */
@ -1613,6 +1615,8 @@ export enum CountryCode {
To = 'TO', To = 'TO',
/** Trinidad & Tobago. */ /** Trinidad & Tobago. */
Tt = 'TT', Tt = 'TT',
/** Tristan da Cunha. */
Ta = 'TA',
/** Tunisia. */ /** Tunisia. */
Tn = 'TN', Tn = 'TN',
/** Turkey. */ /** Turkey. */
@ -1687,7 +1691,7 @@ export type CreditCard = {
export type CreditCardPaymentInput = { export type CreditCardPaymentInput = {
/** The amount of the payment. */ /** The amount of the payment. */
amount: Scalars['Money'] amount: Scalars['Money']
/** A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. */ /** A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. For more information, refer to [Idempotent requests](https://shopify.dev/concepts/about-apis/idempotent-requests). */
idempotencyKey: Scalars['String'] idempotencyKey: Scalars['String']
/** The billing address for the payment. */ /** The billing address for the payment. */
billingAddress: MailingAddressInput billingAddress: MailingAddressInput
@ -1704,7 +1708,7 @@ export type CreditCardPaymentInput = {
export type CreditCardPaymentInputV2 = { export type CreditCardPaymentInputV2 = {
/** The amount and currency of the payment. */ /** The amount and currency of the payment. */
paymentAmount: MoneyInput paymentAmount: MoneyInput
/** A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. */ /** A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. For more information, refer to [Idempotent requests](https://shopify.dev/concepts/about-apis/idempotent-requests). */
idempotencyKey: Scalars['String'] idempotencyKey: Scalars['String']
/** The billing address for the payment. */ /** The billing address for the payment. */
billingAddress: MailingAddressInput billingAddress: MailingAddressInput
@ -1766,10 +1770,6 @@ export enum CurrencyCode {
Bhd = 'BHD', Bhd = 'BHD',
/** Burundian Franc (BIF). */ /** Burundian Franc (BIF). */
Bif = 'BIF', Bif = 'BIF',
/** Belarusian Ruble (BYN). */
Byn = 'BYN',
/** Belarusian Ruble (BYR). */
Byr = 'BYR',
/** Belize Dollar (BZD). */ /** Belize Dollar (BZD). */
Bzd = 'BZD', Bzd = 'BZD',
/** Bermudian Dollar (BMD). */ /** Bermudian Dollar (BMD). */
@ -1816,26 +1816,18 @@ export enum CurrencyCode {
Czk = 'CZK', Czk = 'CZK',
/** Danish Kroner (DKK). */ /** Danish Kroner (DKK). */
Dkk = 'DKK', Dkk = 'DKK',
/** Djiboutian Franc (DJF). */
Djf = 'DJF',
/** Dominican Peso (DOP). */ /** Dominican Peso (DOP). */
Dop = 'DOP', Dop = 'DOP',
/** East Caribbean Dollar (XCD). */ /** East Caribbean Dollar (XCD). */
Xcd = 'XCD', Xcd = 'XCD',
/** Egyptian Pound (EGP). */ /** Egyptian Pound (EGP). */
Egp = 'EGP', Egp = 'EGP',
/** Eritrean Nakfa (ERN). */
Ern = 'ERN',
/** Ethiopian Birr (ETB). */ /** Ethiopian Birr (ETB). */
Etb = 'ETB', Etb = 'ETB',
/** Falkland Islands Pounds (FKP). */
Fkp = 'FKP',
/** CFP Franc (XPF). */ /** CFP Franc (XPF). */
Xpf = 'XPF', Xpf = 'XPF',
/** Fijian Dollars (FJD). */ /** Fijian Dollars (FJD). */
Fjd = 'FJD', Fjd = 'FJD',
/** Gibraltar Pounds (GIP). */
Gip = 'GIP',
/** Gambian Dalasi (GMD). */ /** Gambian Dalasi (GMD). */
Gmd = 'GMD', Gmd = 'GMD',
/** Ghanaian Cedi (GHS). */ /** Ghanaian Cedi (GHS). */
@ -1846,8 +1838,6 @@ export enum CurrencyCode {
Gyd = 'GYD', Gyd = 'GYD',
/** Georgian Lari (GEL). */ /** Georgian Lari (GEL). */
Gel = 'GEL', Gel = 'GEL',
/** Guinean Franc (GNF). */
Gnf = 'GNF',
/** Haitian Gourde (HTG). */ /** Haitian Gourde (HTG). */
Htg = 'HTG', Htg = 'HTG',
/** Honduran Lempira (HNL). */ /** Honduran Lempira (HNL). */
@ -1864,8 +1854,6 @@ export enum CurrencyCode {
Idr = 'IDR', Idr = 'IDR',
/** Israeli New Shekel (NIS). */ /** Israeli New Shekel (NIS). */
Ils = 'ILS', Ils = 'ILS',
/** Iranian Rial (IRR). */
Irr = 'IRR',
/** Iraqi Dinar (IQD). */ /** Iraqi Dinar (IQD). */
Iqd = 'IQD', Iqd = 'IQD',
/** Jamaican Dollars (JMD). */ /** Jamaican Dollars (JMD). */
@ -1880,8 +1868,6 @@ export enum CurrencyCode {
Kzt = 'KZT', Kzt = 'KZT',
/** Kenyan Shilling (KES). */ /** Kenyan Shilling (KES). */
Kes = 'KES', Kes = 'KES',
/** Kiribati Dollar (KID). */
Kid = 'KID',
/** Kuwaiti Dinar (KWD). */ /** Kuwaiti Dinar (KWD). */
Kwd = 'KWD', Kwd = 'KWD',
/** Kyrgyzstani Som (KGS). */ /** Kyrgyzstani Som (KGS). */
@ -1896,8 +1882,6 @@ export enum CurrencyCode {
Lsl = 'LSL', Lsl = 'LSL',
/** Liberian Dollar (LRD). */ /** Liberian Dollar (LRD). */
Lrd = 'LRD', Lrd = 'LRD',
/** Libyan Dinar (LYD). */
Lyd = 'LYD',
/** Lithuanian Litai (LTL). */ /** Lithuanian Litai (LTL). */
Ltl = 'LTL', Ltl = 'LTL',
/** Malagasy Ariary (MGA). */ /** Malagasy Ariary (MGA). */
@ -1910,8 +1894,6 @@ export enum CurrencyCode {
Mwk = 'MWK', Mwk = 'MWK',
/** Maldivian Rufiyaa (MVR). */ /** Maldivian Rufiyaa (MVR). */
Mvr = 'MVR', Mvr = 'MVR',
/** Mauritanian Ouguiya (MRU). */
Mru = 'MRU',
/** Mexican Pesos (MXN). */ /** Mexican Pesos (MXN). */
Mxn = 'MXN', Mxn = 'MXN',
/** Malaysian Ringgits (MYR). */ /** Malaysian Ringgits (MYR). */
@ -1966,8 +1948,6 @@ export enum CurrencyCode {
Rwf = 'RWF', Rwf = 'RWF',
/** Samoan Tala (WST). */ /** Samoan Tala (WST). */
Wst = 'WST', Wst = 'WST',
/** Saint Helena Pounds (SHP). */
Shp = 'SHP',
/** Saudi Riyal (SAR). */ /** Saudi Riyal (SAR). */
Sar = 'SAR', Sar = 'SAR',
/** Sao Tome And Principe Dobra (STD). */ /** Sao Tome And Principe Dobra (STD). */
@ -1976,14 +1956,10 @@ export enum CurrencyCode {
Rsd = 'RSD', Rsd = 'RSD',
/** Seychellois Rupee (SCR). */ /** Seychellois Rupee (SCR). */
Scr = 'SCR', Scr = 'SCR',
/** Sierra Leonean Leone (SLL). */
Sll = 'SLL',
/** Singapore Dollars (SGD). */ /** Singapore Dollars (SGD). */
Sgd = 'SGD', Sgd = 'SGD',
/** Sudanese Pound (SDG). */ /** Sudanese Pound (SDG). */
Sdg = 'SDG', Sdg = 'SDG',
/** Somali Shilling (SOS). */
Sos = 'SOS',
/** Syrian Pound (SYP). */ /** Syrian Pound (SYP). */
Syp = 'SYP', Syp = 'SYP',
/** South African Rand (ZAR). */ /** South African Rand (ZAR). */
@ -2008,12 +1984,8 @@ export enum CurrencyCode {
Twd = 'TWD', Twd = 'TWD',
/** Thai baht (THB). */ /** Thai baht (THB). */
Thb = 'THB', Thb = 'THB',
/** Tajikistani Somoni (TJS). */
Tjs = 'TJS',
/** Tanzanian Shilling (TZS). */ /** Tanzanian Shilling (TZS). */
Tzs = 'TZS', Tzs = 'TZS',
/** Tongan Pa'anga (TOP). */
Top = 'TOP',
/** Trinidad and Tobago Dollars (TTD). */ /** Trinidad and Tobago Dollars (TTD). */
Ttd = 'TTD', Ttd = 'TTD',
/** Tunisian Dinar (TND). */ /** Tunisian Dinar (TND). */
@ -2034,10 +2006,6 @@ export enum CurrencyCode {
Uzs = 'UZS', Uzs = 'UZS',
/** Vanuatu Vatu (VUV). */ /** Vanuatu Vatu (VUV). */
Vuv = 'VUV', Vuv = 'VUV',
/** Venezuelan Bolivares (VEF). */
Vef = 'VEF',
/** Venezuelan Bolivares (VES). */
Ves = 'VES',
/** Vietnamese đồng (VND). */ /** Vietnamese đồng (VND). */
Vnd = 'VND', Vnd = 'VND',
/** West African CFA franc (XOF). */ /** West African CFA franc (XOF). */
@ -2046,6 +2014,42 @@ export enum CurrencyCode {
Yer = 'YER', Yer = 'YER',
/** Zambian Kwacha (ZMW). */ /** Zambian Kwacha (ZMW). */
Zmw = 'ZMW', Zmw = 'ZMW',
/** Belarusian Ruble (BYN). */
Byn = 'BYN',
/** Belarusian Ruble (BYR). */
Byr = 'BYR',
/** Djiboutian Franc (DJF). */
Djf = 'DJF',
/** Eritrean Nakfa (ERN). */
Ern = 'ERN',
/** Falkland Islands Pounds (FKP). */
Fkp = 'FKP',
/** Gibraltar Pounds (GIP). */
Gip = 'GIP',
/** Guinean Franc (GNF). */
Gnf = 'GNF',
/** Iranian Rial (IRR). */
Irr = 'IRR',
/** Kiribati Dollar (KID). */
Kid = 'KID',
/** Libyan Dinar (LYD). */
Lyd = 'LYD',
/** Mauritanian Ouguiya (MRU). */
Mru = 'MRU',
/** Sierra Leonean Leone (SLL). */
Sll = 'SLL',
/** Saint Helena Pounds (SHP). */
Shp = 'SHP',
/** Somali Shilling (SOS). */
Sos = 'SOS',
/** Tajikistani Somoni (TJS). */
Tjs = 'TJS',
/** Tongan Pa'anga (TOP). */
Top = 'TOP',
/** Venezuelan Bolivares (VEF). */
Vef = 'VEF',
/** Venezuelan Bolivares (VES). */
Ves = 'VES',
} }
/** A customer represents a customer account with the shop. Customer accounts store contact information for the customer, saving logged-in customers the trouble of having to provide it at every checkout. */ /** A customer represents a customer account with the shop. Customer accounts store contact information for the customer, saving logged-in customers the trouble of having to provide it at every checkout. */
@ -3817,7 +3821,11 @@ export type Payment = Node & {
errorMessage?: Maybe<Scalars['String']> errorMessage?: Maybe<Scalars['String']>
/** Globally unique identifier. */ /** Globally unique identifier. */
id: Scalars['ID'] id: Scalars['ID']
/** A client-side generated token to identify a payment and perform idempotent operations. */ /**
* A client-side generated token to identify a payment and perform idempotent operations.
* For more information, refer to
* [Idempotent requests](https://shopify.dev/concepts/about-apis/idempotent-requests).
*/
idempotencyKey?: Maybe<Scalars['String']> idempotencyKey?: Maybe<Scalars['String']>
/** The URL where the customer needs to be redirected so they can complete the 3D Secure payment flow. */ /** The URL where the customer needs to be redirected so they can complete the 3D Secure payment flow. */
nextActionUrl?: Maybe<Scalars['URL']> nextActionUrl?: Maybe<Scalars['URL']>
@ -4386,7 +4394,9 @@ export type QueryRoot = {
collections: CollectionConnection collections: CollectionConnection
/** Find a customer by its access token. */ /** Find a customer by its access token. */
customer?: Maybe<Customer> customer?: Maybe<Customer>
/** Returns a specific node by ID. */
node?: Maybe<Node> node?: Maybe<Node>
/** Returns the list of nodes with the given IDs. */
nodes: Array<Maybe<Node>> nodes: Array<Maybe<Node>>
/** Find a page by its handle. */ /** Find a page by its handle. */
pageByHandle?: Maybe<Page> pageByHandle?: Maybe<Page>
@ -4768,7 +4778,7 @@ export type StringEdge = {
export type TokenizedPaymentInput = { export type TokenizedPaymentInput = {
/** The amount of the payment. */ /** The amount of the payment. */
amount: Scalars['Money'] amount: Scalars['Money']
/** A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. */ /** A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. For more information, refer to [Idempotent requests](https://shopify.dev/concepts/about-apis/idempotent-requests). */
idempotencyKey: Scalars['String'] idempotencyKey: Scalars['String']
/** The billing address for the payment. */ /** The billing address for the payment. */
billingAddress: MailingAddressInput billingAddress: MailingAddressInput
@ -4789,7 +4799,7 @@ export type TokenizedPaymentInput = {
export type TokenizedPaymentInputV2 = { export type TokenizedPaymentInputV2 = {
/** The amount and currency of the payment. */ /** The amount and currency of the payment. */
paymentAmount: MoneyInput paymentAmount: MoneyInput
/** A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. */ /** A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. For more information, refer to [Idempotent requests](https://shopify.dev/concepts/about-apis/idempotent-requests). */
idempotencyKey: Scalars['String'] idempotencyKey: Scalars['String']
/** The billing address for the payment. */ /** The billing address for the payment. */
billingAddress: MailingAddressInput billingAddress: MailingAddressInput
@ -4810,7 +4820,7 @@ export type TokenizedPaymentInputV2 = {
export type TokenizedPaymentInputV3 = { export type TokenizedPaymentInputV3 = {
/** The amount and currency of the payment. */ /** The amount and currency of the payment. */
paymentAmount: MoneyInput paymentAmount: MoneyInput
/** A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. */ /** A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. For more information, refer to [Idempotent requests](https://shopify.dev/concepts/about-apis/idempotent-requests). */
idempotencyKey: Scalars['String'] idempotencyKey: Scalars['String']
/** The billing address for the payment. */ /** The billing address for the payment. */
billingAddress: MailingAddressInput billingAddress: MailingAddressInput
@ -4847,18 +4857,32 @@ export type Transaction = {
test: Scalars['Boolean'] test: Scalars['Boolean']
} }
/** The different kinds of order transactions. */
export enum TransactionKind { export enum TransactionKind {
/** An authorization and capture performed together in a single step. */
Sale = 'SALE', Sale = 'SALE',
/** A transfer of the money that was reserved during the authorization stage. */
Capture = 'CAPTURE', Capture = 'CAPTURE',
/**
* An amount reserved against the cardholder's funding source.
* Money does not change hands until the authorization is captured.
*/
Authorization = 'AUTHORIZATION', Authorization = 'AUTHORIZATION',
/** An authorization for a payment taken with an EMV credit card reader. */
EmvAuthorization = 'EMV_AUTHORIZATION', EmvAuthorization = 'EMV_AUTHORIZATION',
/** Money returned to the customer when they have paid too much. */
Change = 'CHANGE', Change = 'CHANGE',
} }
/** Transaction statuses describe the status of a transaction. */
export enum TransactionStatus { export enum TransactionStatus {
/** The transaction is pending. */
Pending = 'PENDING', Pending = 'PENDING',
/** The transaction succeeded. */
Success = 'SUCCESS', Success = 'SUCCESS',
/** The transaction failed. */
Failure = 'FAILURE', Failure = 'FAILURE',
/** There was an error while processing the transaction. */
Error = 'ERROR', Error = 'ERROR',
} }
@ -4967,19 +4991,590 @@ export enum WeightUnit {
Ounces = 'OUNCES', Ounces = 'OUNCES',
} }
export type Unnamed_1_QueryVariables = Exact<{ export type AssociateCustomerWithCheckoutMutationVariables = Exact<{
checkoutId: Scalars['ID']
customerAccessToken: Scalars['String']
}>
export type AssociateCustomerWithCheckoutMutation = {
__typename?: 'Mutation'
} & {
checkoutCustomerAssociateV2?: Maybe<
{ __typename?: 'CheckoutCustomerAssociateV2Payload' } & {
checkout?: Maybe<{ __typename?: 'Checkout' } & Pick<Checkout, 'id'>>
checkoutUserErrors: Array<
{ __typename?: 'CheckoutUserError' } & Pick<
CheckoutUserError,
'code' | 'field' | 'message'
>
>
customer?: Maybe<{ __typename?: 'Customer' } & Pick<Customer, 'id'>>
}
>
}
export type CheckoutCreateMutationVariables = Exact<{
input?: Maybe<CheckoutCreateInput>
}>
export type CheckoutCreateMutation = { __typename?: 'Mutation' } & {
checkoutCreate?: Maybe<
{ __typename?: 'CheckoutCreatePayload' } & {
checkoutUserErrors: Array<
{ __typename?: 'CheckoutUserError' } & Pick<
CheckoutUserError,
'code' | 'field' | 'message'
>
>
checkout?: Maybe<{ __typename?: 'Checkout' } & CheckoutDetailsFragment>
}
>
}
export type CheckoutLineItemAddMutationVariables = Exact<{
checkoutId: Scalars['ID']
lineItems: Array<CheckoutLineItemInput> | CheckoutLineItemInput
}>
export type CheckoutLineItemAddMutation = { __typename?: 'Mutation' } & {
checkoutLineItemsAdd?: Maybe<
{ __typename?: 'CheckoutLineItemsAddPayload' } & {
checkoutUserErrors: Array<
{ __typename?: 'CheckoutUserError' } & Pick<
CheckoutUserError,
'code' | 'field' | 'message'
>
>
checkout?: Maybe<{ __typename?: 'Checkout' } & CheckoutDetailsFragment>
}
>
}
export type CheckoutLineItemRemoveMutationVariables = Exact<{
checkoutId: Scalars['ID']
lineItemIds: Array<Scalars['ID']> | Scalars['ID']
}>
export type CheckoutLineItemRemoveMutation = { __typename?: 'Mutation' } & {
checkoutLineItemsRemove?: Maybe<
{ __typename?: 'CheckoutLineItemsRemovePayload' } & {
checkoutUserErrors: Array<
{ __typename?: 'CheckoutUserError' } & Pick<
CheckoutUserError,
'code' | 'field' | 'message'
>
>
checkout?: Maybe<{ __typename?: 'Checkout' } & CheckoutDetailsFragment>
}
>
}
export type CheckoutLineItemUpdateMutationVariables = Exact<{
checkoutId: Scalars['ID']
lineItems: Array<CheckoutLineItemUpdateInput> | CheckoutLineItemUpdateInput
}>
export type CheckoutLineItemUpdateMutation = { __typename?: 'Mutation' } & {
checkoutLineItemsUpdate?: Maybe<
{ __typename?: 'CheckoutLineItemsUpdatePayload' } & {
checkoutUserErrors: Array<
{ __typename?: 'CheckoutUserError' } & Pick<
CheckoutUserError,
'code' | 'field' | 'message'
>
>
checkout?: Maybe<{ __typename?: 'Checkout' } & CheckoutDetailsFragment>
}
>
}
export type CustomerAccessTokenCreateMutationVariables = Exact<{
input: CustomerAccessTokenCreateInput
}>
export type CustomerAccessTokenCreateMutation = { __typename?: 'Mutation' } & {
customerAccessTokenCreate?: Maybe<
{ __typename?: 'CustomerAccessTokenCreatePayload' } & {
customerAccessToken?: Maybe<
{ __typename?: 'CustomerAccessToken' } & Pick<
CustomerAccessToken,
'accessToken' | 'expiresAt'
>
>
customerUserErrors: Array<
{ __typename?: 'CustomerUserError' } & Pick<
CustomerUserError,
'code' | 'field' | 'message'
>
>
}
>
}
export type CustomerAccessTokenDeleteMutationVariables = Exact<{
customerAccessToken: Scalars['String']
}>
export type CustomerAccessTokenDeleteMutation = { __typename?: 'Mutation' } & {
customerAccessTokenDelete?: Maybe<
{ __typename?: 'CustomerAccessTokenDeletePayload' } & Pick<
CustomerAccessTokenDeletePayload,
'deletedAccessToken' | 'deletedCustomerAccessTokenId'
> & {
userErrors: Array<
{ __typename?: 'UserError' } & Pick<UserError, 'field' | 'message'>
>
}
>
}
export type CustomerActivateByUrlMutationVariables = Exact<{
activationUrl: Scalars['URL']
password: Scalars['String']
}>
export type CustomerActivateByUrlMutation = { __typename?: 'Mutation' } & {
customerActivateByUrl?: Maybe<
{ __typename?: 'CustomerActivateByUrlPayload' } & {
customer?: Maybe<{ __typename?: 'Customer' } & Pick<Customer, 'id'>>
customerAccessToken?: Maybe<
{ __typename?: 'CustomerAccessToken' } & Pick<
CustomerAccessToken,
'accessToken' | 'expiresAt'
>
>
customerUserErrors: Array<
{ __typename?: 'CustomerUserError' } & Pick<
CustomerUserError,
'code' | 'field' | 'message'
>
>
}
>
}
export type CustomerActivateMutationVariables = Exact<{
id: Scalars['ID']
input: CustomerActivateInput
}>
export type CustomerActivateMutation = { __typename?: 'Mutation' } & {
customerActivate?: Maybe<
{ __typename?: 'CustomerActivatePayload' } & {
customer?: Maybe<{ __typename?: 'Customer' } & Pick<Customer, 'id'>>
customerAccessToken?: Maybe<
{ __typename?: 'CustomerAccessToken' } & Pick<
CustomerAccessToken,
'accessToken' | 'expiresAt'
>
>
customerUserErrors: Array<
{ __typename?: 'CustomerUserError' } & Pick<
CustomerUserError,
'code' | 'field' | 'message'
>
>
}
>
}
export type CustomerCreateMutationVariables = Exact<{
input: CustomerCreateInput
}>
export type CustomerCreateMutation = { __typename?: 'Mutation' } & {
customerCreate?: Maybe<
{ __typename?: 'CustomerCreatePayload' } & {
customerUserErrors: Array<
{ __typename?: 'CustomerUserError' } & Pick<
CustomerUserError,
'code' | 'field' | 'message'
>
>
customer?: Maybe<{ __typename?: 'Customer' } & Pick<Customer, 'id'>>
}
>
}
export type GetSiteCollectionsQueryVariables = Exact<{
first: Scalars['Int'] first: Scalars['Int']
}> }>
export type Unnamed_1_Query = { __typename?: 'QueryRoot' } & { export type GetSiteCollectionsQuery = { __typename?: 'QueryRoot' } & {
pages: { __typename?: 'PageConnection' } & { collections: { __typename?: 'CollectionConnection' } & {
edges: Array< edges: Array<
{ __typename?: 'PageEdge' } & { { __typename?: 'CollectionEdge' } & {
node: { __typename?: 'Page' } & Pick< node: { __typename?: 'Collection' } & Pick<
Page, Collection,
'id' | 'title' | 'handle' | 'body' | 'bodySummary' | 'url' 'id' | 'title' | 'handle'
> >
} }
> >
} }
} }
export type GetAllPagesQueryVariables = Exact<{
first?: Maybe<Scalars['Int']>
}>
export type GetAllPagesQuery = { __typename?: 'QueryRoot' } & {
pages: { __typename?: 'PageConnection' } & {
edges: Array<
{ __typename?: 'PageEdge' } & {
node: { __typename?: 'Page' } & Pick<Page, 'id' | 'title' | 'handle'>
}
>
}
}
export type GetAllProductVendorsQueryVariables = Exact<{
first?: Maybe<Scalars['Int']>
cursor?: Maybe<Scalars['String']>
}>
export type GetAllProductVendorsQuery = { __typename?: 'QueryRoot' } & {
products: { __typename?: 'ProductConnection' } & {
pageInfo: { __typename?: 'PageInfo' } & Pick<
PageInfo,
'hasNextPage' | 'hasPreviousPage'
>
edges: Array<
{ __typename?: 'ProductEdge' } & Pick<ProductEdge, 'cursor'> & {
node: { __typename?: 'Product' } & Pick<Product, 'vendor'>
}
>
}
}
export type GetAllProductPathsQueryVariables = Exact<{
first?: Maybe<Scalars['Int']>
cursor?: Maybe<Scalars['String']>
}>
export type GetAllProductPathsQuery = { __typename?: 'QueryRoot' } & {
products: { __typename?: 'ProductConnection' } & {
pageInfo: { __typename?: 'PageInfo' } & Pick<
PageInfo,
'hasNextPage' | 'hasPreviousPage'
>
edges: Array<
{ __typename?: 'ProductEdge' } & Pick<ProductEdge, 'cursor'> & {
node: { __typename?: 'Product' } & Pick<Product, 'handle'>
}
>
}
}
export type ProductConnectionFragment = { __typename?: 'ProductConnection' } & {
pageInfo: { __typename?: 'PageInfo' } & Pick<
PageInfo,
'hasNextPage' | 'hasPreviousPage'
>
edges: Array<
{ __typename?: 'ProductEdge' } & {
node: { __typename?: 'Product' } & Pick<
Product,
'id' | 'title' | 'vendor' | 'handle'
> & {
priceRange: { __typename?: 'ProductPriceRange' } & {
minVariantPrice: { __typename?: 'MoneyV2' } & Pick<
MoneyV2,
'amount' | 'currencyCode'
>
}
images: { __typename?: 'ImageConnection' } & {
pageInfo: { __typename?: 'PageInfo' } & Pick<
PageInfo,
'hasNextPage' | 'hasPreviousPage'
>
edges: Array<
{ __typename?: 'ImageEdge' } & {
node: { __typename?: 'Image' } & Pick<
Image,
'originalSrc' | 'altText' | 'width' | 'height'
>
}
>
}
}
}
>
}
export type GetAllProductsQueryVariables = Exact<{
first?: Maybe<Scalars['Int']>
query?: Maybe<Scalars['String']>
sortKey?: Maybe<ProductSortKeys>
reverse?: Maybe<Scalars['Boolean']>
}>
export type GetAllProductsQuery = { __typename?: 'QueryRoot' } & {
products: { __typename?: 'ProductConnection' } & ProductConnectionFragment
}
export type CheckoutDetailsFragment = { __typename?: 'Checkout' } & Pick<
Checkout,
'id' | 'webUrl' | 'completedAt' | 'createdAt' | 'taxesIncluded'
> & {
subtotalPriceV2: { __typename?: 'MoneyV2' } & Pick<
MoneyV2,
'amount' | 'currencyCode'
>
totalTaxV2: { __typename?: 'MoneyV2' } & Pick<
MoneyV2,
'amount' | 'currencyCode'
>
totalPriceV2: { __typename?: 'MoneyV2' } & Pick<
MoneyV2,
'amount' | 'currencyCode'
>
lineItems: { __typename?: 'CheckoutLineItemConnection' } & {
pageInfo: { __typename?: 'PageInfo' } & Pick<
PageInfo,
'hasNextPage' | 'hasPreviousPage'
>
edges: Array<
{ __typename?: 'CheckoutLineItemEdge' } & {
node: { __typename?: 'CheckoutLineItem' } & Pick<
CheckoutLineItem,
'id' | 'title' | 'quantity'
> & {
variant?: Maybe<
{ __typename?: 'ProductVariant' } & Pick<
ProductVariant,
'id' | 'sku' | 'title'
> & {
image?: Maybe<
{ __typename?: 'Image' } & Pick<
Image,
'originalSrc' | 'altText' | 'width' | 'height'
>
>
priceV2: { __typename?: 'MoneyV2' } & Pick<
MoneyV2,
'amount' | 'currencyCode'
>
compareAtPriceV2?: Maybe<
{ __typename?: 'MoneyV2' } & Pick<
MoneyV2,
'amount' | 'currencyCode'
>
>
product: { __typename?: 'Product' } & Pick<
Product,
'handle'
>
}
>
}
}
>
}
}
export type GetCheckoutQueryVariables = Exact<{
checkoutId: Scalars['ID']
}>
export type GetCheckoutQuery = { __typename?: 'QueryRoot' } & {
node?: Maybe<
| { __typename?: 'AppliedGiftCard' }
| { __typename?: 'Article' }
| { __typename?: 'Blog' }
| ({ __typename?: 'Checkout' } & CheckoutDetailsFragment)
| { __typename?: 'CheckoutLineItem' }
| { __typename?: 'Collection' }
| { __typename?: 'Comment' }
| { __typename?: 'ExternalVideo' }
| { __typename?: 'MailingAddress' }
| { __typename?: 'MediaImage' }
| { __typename?: 'Metafield' }
| { __typename?: 'Model3d' }
| { __typename?: 'Order' }
| { __typename?: 'Page' }
| { __typename?: 'Payment' }
| { __typename?: 'Product' }
| { __typename?: 'ProductOption' }
| { __typename?: 'ProductVariant' }
| { __typename?: 'ShopPolicy' }
| { __typename?: 'Video' }
>
}
export type GetProductsFromCollectionQueryVariables = Exact<{
categoryId: Scalars['ID']
first?: Maybe<Scalars['Int']>
sortKey?: Maybe<ProductCollectionSortKeys>
reverse?: Maybe<Scalars['Boolean']>
}>
export type GetProductsFromCollectionQuery = { __typename?: 'QueryRoot' } & {
node?: Maybe<
| ({ __typename?: 'AppliedGiftCard' } & Pick<AppliedGiftCard, 'id'>)
| ({ __typename?: 'Article' } & Pick<Article, 'id'>)
| ({ __typename?: 'Blog' } & Pick<Blog, 'id'>)
| ({ __typename?: 'Checkout' } & Pick<Checkout, 'id'>)
| ({ __typename?: 'CheckoutLineItem' } & Pick<CheckoutLineItem, 'id'>)
| ({ __typename?: 'Collection' } & Pick<Collection, 'id'> & {
products: {
__typename?: 'ProductConnection'
} & ProductConnectionFragment
})
| ({ __typename?: 'Comment' } & Pick<Comment, 'id'>)
| ({ __typename?: 'ExternalVideo' } & Pick<ExternalVideo, 'id'>)
| ({ __typename?: 'MailingAddress' } & Pick<MailingAddress, 'id'>)
| ({ __typename?: 'MediaImage' } & Pick<MediaImage, 'id'>)
| ({ __typename?: 'Metafield' } & Pick<Metafield, 'id'>)
| ({ __typename?: 'Model3d' } & Pick<Model3d, 'id'>)
| ({ __typename?: 'Order' } & Pick<Order, 'id'>)
| ({ __typename?: 'Page' } & Pick<Page, 'id'>)
| ({ __typename?: 'Payment' } & Pick<Payment, 'id'>)
| ({ __typename?: 'Product' } & Pick<Product, 'id'>)
| ({ __typename?: 'ProductOption' } & Pick<ProductOption, 'id'>)
| ({ __typename?: 'ProductVariant' } & Pick<ProductVariant, 'id'>)
| ({ __typename?: 'ShopPolicy' } & Pick<ShopPolicy, 'id'>)
| ({ __typename?: 'Video' } & Pick<Video, 'id'>)
>
}
export type GetCustomerIdQueryVariables = Exact<{
customerAccessToken: Scalars['String']
}>
export type GetCustomerIdQuery = { __typename?: 'QueryRoot' } & {
customer?: Maybe<{ __typename?: 'Customer' } & Pick<Customer, 'id'>>
}
export type GetCustomerQueryVariables = Exact<{
customerAccessToken: Scalars['String']
}>
export type GetCustomerQuery = { __typename?: 'QueryRoot' } & {
customer?: Maybe<
{ __typename?: 'Customer' } & Pick<
Customer,
| 'id'
| 'firstName'
| 'lastName'
| 'displayName'
| 'email'
| 'phone'
| 'tags'
| 'acceptsMarketing'
| 'createdAt'
>
>
}
export type GetPageQueryVariables = Exact<{
id: Scalars['ID']
}>
export type GetPageQuery = { __typename?: 'QueryRoot' } & {
node?: Maybe<
| ({ __typename?: 'AppliedGiftCard' } & Pick<AppliedGiftCard, 'id'>)
| ({ __typename?: 'Article' } & Pick<Article, 'id'>)
| ({ __typename?: 'Blog' } & Pick<Blog, 'id'>)
| ({ __typename?: 'Checkout' } & Pick<Checkout, 'id'>)
| ({ __typename?: 'CheckoutLineItem' } & Pick<CheckoutLineItem, 'id'>)
| ({ __typename?: 'Collection' } & Pick<Collection, 'id'>)
| ({ __typename?: 'Comment' } & Pick<Comment, 'id'>)
| ({ __typename?: 'ExternalVideo' } & Pick<ExternalVideo, 'id'>)
| ({ __typename?: 'MailingAddress' } & Pick<MailingAddress, 'id'>)
| ({ __typename?: 'MediaImage' } & Pick<MediaImage, 'id'>)
| ({ __typename?: 'Metafield' } & Pick<Metafield, 'id'>)
| ({ __typename?: 'Model3d' } & Pick<Model3d, 'id'>)
| ({ __typename?: 'Order' } & Pick<Order, 'id'>)
| ({ __typename?: 'Page' } & Pick<
Page,
'title' | 'handle' | 'body' | 'bodySummary' | 'id'
>)
| ({ __typename?: 'Payment' } & Pick<Payment, 'id'>)
| ({ __typename?: 'Product' } & Pick<Product, 'id'>)
| ({ __typename?: 'ProductOption' } & Pick<ProductOption, 'id'>)
| ({ __typename?: 'ProductVariant' } & Pick<ProductVariant, 'id'>)
| ({ __typename?: 'ShopPolicy' } & Pick<ShopPolicy, 'id'>)
| ({ __typename?: 'Video' } & Pick<Video, 'id'>)
>
}
export type GetProductBySlugQueryVariables = Exact<{
slug: Scalars['String']
}>
export type GetProductBySlugQuery = { __typename?: 'QueryRoot' } & {
productByHandle?: Maybe<
{ __typename?: 'Product' } & Pick<
Product,
| 'id'
| 'handle'
| 'title'
| 'productType'
| 'vendor'
| 'description'
| 'descriptionHtml'
> & {
options: Array<
{ __typename?: 'ProductOption' } & Pick<
ProductOption,
'id' | 'name' | 'values'
>
>
priceRange: { __typename?: 'ProductPriceRange' } & {
maxVariantPrice: { __typename?: 'MoneyV2' } & Pick<
MoneyV2,
'amount' | 'currencyCode'
>
minVariantPrice: { __typename?: 'MoneyV2' } & Pick<
MoneyV2,
'amount' | 'currencyCode'
>
}
variants: { __typename?: 'ProductVariantConnection' } & {
pageInfo: { __typename?: 'PageInfo' } & Pick<
PageInfo,
'hasNextPage' | 'hasPreviousPage'
>
edges: Array<
{ __typename?: 'ProductVariantEdge' } & {
node: { __typename?: 'ProductVariant' } & Pick<
ProductVariant,
'id' | 'title' | 'sku'
> & {
selectedOptions: Array<
{ __typename?: 'SelectedOption' } & Pick<
SelectedOption,
'name' | 'value'
>
>
priceV2: { __typename?: 'MoneyV2' } & Pick<
MoneyV2,
'amount' | 'currencyCode'
>
compareAtPriceV2?: Maybe<
{ __typename?: 'MoneyV2' } & Pick<
MoneyV2,
'amount' | 'currencyCode'
>
>
}
}
>
}
images: { __typename?: 'ImageConnection' } & {
pageInfo: { __typename?: 'PageInfo' } & Pick<
PageInfo,
'hasNextPage' | 'hasPreviousPage'
>
edges: Array<
{ __typename?: 'ImageEdge' } & {
node: { __typename?: 'Image' } & Pick<
Image,
'originalSrc' | 'altText' | 'width' | 'height'
>
}
>
}
}
>
}

View File

@ -28,7 +28,7 @@ type ApiVersion {
handle: String! handle: String!
""" """
Whether the version is supported by Shopify. Whether the version is actively supported by Shopify. Supported API versions are guaranteed to be stable. Unsupported API versions include unstable, release candidate, and end-of-life versions that are marked as unsupported. For more information, refer to [Versioning](https://shopify.dev/concepts/about-apis/versioning).
""" """
supported: Boolean! supported: Boolean!
} }
@ -547,32 +547,32 @@ Card brand, such as Visa or Mastercard, which can be used for payments.
""" """
enum CardBrand { enum CardBrand {
""" """
Visa Visa.
""" """
VISA VISA
""" """
Mastercard Mastercard.
""" """
MASTERCARD MASTERCARD
""" """
Discover Discover.
""" """
DISCOVER DISCOVER
""" """
American Express American Express.
""" """
AMERICAN_EXPRESS AMERICAN_EXPRESS
""" """
Diners Club Diners Club.
""" """
DINERS_CLUB DINERS_CLUB
""" """
JCB JCB.
""" """
JCB JCB
} }
@ -2142,6 +2142,11 @@ enum CountryCode {
""" """
AW AW
"""
Ascension Island.
"""
AC
""" """
Australia. Australia.
""" """
@ -3187,6 +3192,11 @@ enum CountryCode {
""" """
TT TT
"""
Tristan da Cunha.
"""
TA
""" """
Tunisia. Tunisia.
""" """
@ -3354,7 +3364,7 @@ input CreditCardPaymentInput {
amount: Money! amount: Money!
""" """
A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. For more information, refer to [Idempotent requests](https://shopify.dev/concepts/about-apis/idempotent-requests).
""" """
idempotencyKey: String! idempotencyKey: String!
@ -3385,7 +3395,7 @@ input CreditCardPaymentInputV2 {
paymentAmount: MoneyInput! paymentAmount: MoneyInput!
""" """
A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. For more information, refer to [Idempotent requests](https://shopify.dev/concepts/about-apis/idempotent-requests).
""" """
idempotencyKey: String! idempotencyKey: String!
@ -3529,16 +3539,6 @@ enum CurrencyCode {
""" """
BIF BIF
"""
Belarusian Ruble (BYN).
"""
BYN
"""
Belarusian Ruble (BYR).
"""
BYR
""" """
Belize Dollar (BZD). Belize Dollar (BZD).
""" """
@ -3654,11 +3654,6 @@ enum CurrencyCode {
""" """
DKK DKK
"""
Djiboutian Franc (DJF).
"""
DJF
""" """
Dominican Peso (DOP). Dominican Peso (DOP).
""" """
@ -3674,21 +3669,11 @@ enum CurrencyCode {
""" """
EGP EGP
"""
Eritrean Nakfa (ERN).
"""
ERN
""" """
Ethiopian Birr (ETB). Ethiopian Birr (ETB).
""" """
ETB ETB
"""
Falkland Islands Pounds (FKP).
"""
FKP
""" """
CFP Franc (XPF). CFP Franc (XPF).
""" """
@ -3699,11 +3684,6 @@ enum CurrencyCode {
""" """
FJD FJD
"""
Gibraltar Pounds (GIP).
"""
GIP
""" """
Gambian Dalasi (GMD). Gambian Dalasi (GMD).
""" """
@ -3729,11 +3709,6 @@ enum CurrencyCode {
""" """
GEL GEL
"""
Guinean Franc (GNF).
"""
GNF
""" """
Haitian Gourde (HTG). Haitian Gourde (HTG).
""" """
@ -3774,11 +3749,6 @@ enum CurrencyCode {
""" """
ILS ILS
"""
Iranian Rial (IRR).
"""
IRR
""" """
Iraqi Dinar (IQD). Iraqi Dinar (IQD).
""" """
@ -3814,11 +3784,6 @@ enum CurrencyCode {
""" """
KES KES
"""
Kiribati Dollar (KID).
"""
KID
""" """
Kuwaiti Dinar (KWD). Kuwaiti Dinar (KWD).
""" """
@ -3854,11 +3819,6 @@ enum CurrencyCode {
""" """
LRD LRD
"""
Libyan Dinar (LYD).
"""
LYD
""" """
Lithuanian Litai (LTL). Lithuanian Litai (LTL).
""" """
@ -3889,11 +3849,6 @@ enum CurrencyCode {
""" """
MVR MVR
"""
Mauritanian Ouguiya (MRU).
"""
MRU
""" """
Mexican Pesos (MXN). Mexican Pesos (MXN).
""" """
@ -4029,11 +3984,6 @@ enum CurrencyCode {
""" """
WST WST
"""
Saint Helena Pounds (SHP).
"""
SHP
""" """
Saudi Riyal (SAR). Saudi Riyal (SAR).
""" """
@ -4054,11 +4004,6 @@ enum CurrencyCode {
""" """
SCR SCR
"""
Sierra Leonean Leone (SLL).
"""
SLL
""" """
Singapore Dollars (SGD). Singapore Dollars (SGD).
""" """
@ -4069,11 +4014,6 @@ enum CurrencyCode {
""" """
SDG SDG
"""
Somali Shilling (SOS).
"""
SOS
""" """
Syrian Pound (SYP). Syrian Pound (SYP).
""" """
@ -4134,21 +4074,11 @@ enum CurrencyCode {
""" """
THB THB
"""
Tajikistani Somoni (TJS).
"""
TJS
""" """
Tanzanian Shilling (TZS). Tanzanian Shilling (TZS).
""" """
TZS TZS
"""
Tongan Pa'anga (TOP).
"""
TOP
""" """
Trinidad and Tobago Dollars (TTD). Trinidad and Tobago Dollars (TTD).
""" """
@ -4199,16 +4129,6 @@ enum CurrencyCode {
""" """
VUV VUV
"""
Venezuelan Bolivares (VEF).
"""
VEF
"""
Venezuelan Bolivares (VES).
"""
VES
""" """
Vietnamese đồng (VND). Vietnamese đồng (VND).
""" """
@ -4228,6 +4148,96 @@ enum CurrencyCode {
Zambian Kwacha (ZMW). Zambian Kwacha (ZMW).
""" """
ZMW ZMW
"""
Belarusian Ruble (BYN).
"""
BYN
"""
Belarusian Ruble (BYR).
"""
BYR
"""
Djiboutian Franc (DJF).
"""
DJF
"""
Eritrean Nakfa (ERN).
"""
ERN
"""
Falkland Islands Pounds (FKP).
"""
FKP
"""
Gibraltar Pounds (GIP).
"""
GIP
"""
Guinean Franc (GNF).
"""
GNF
"""
Iranian Rial (IRR).
"""
IRR
"""
Kiribati Dollar (KID).
"""
KID
"""
Libyan Dinar (LYD).
"""
LYD
"""
Mauritanian Ouguiya (MRU).
"""
MRU
"""
Sierra Leonean Leone (SLL).
"""
SLL
"""
Saint Helena Pounds (SHP).
"""
SHP
"""
Somali Shilling (SOS).
"""
SOS
"""
Tajikistani Somoni (TJS).
"""
TJS
"""
Tongan Pa'anga (TOP).
"""
TOP
"""
Venezuelan Bolivares (VEF).
"""
VEF
"""
Venezuelan Bolivares (VES).
"""
VES
} }
""" """
@ -7355,6 +7365,8 @@ type Payment implements Node {
""" """
A client-side generated token to identify a payment and perform idempotent operations. A client-side generated token to identify a payment and perform idempotent operations.
For more information, refer to
[Idempotent requests](https://shopify.dev/concepts/about-apis/idempotent-requests).
""" """
idempotencyKey: String idempotencyKey: String
@ -8589,12 +8601,20 @@ type QueryRoot {
""" """
customerAccessToken: String! customerAccessToken: String!
): Customer ): Customer
"""
Returns a specific node by ID.
"""
node( node(
""" """
The ID of the Node to return. The ID of the Node to return.
""" """
id: ID! id: ID!
): Node ): Node
"""
Returns the list of nodes with the given IDs.
"""
nodes( nodes(
""" """
The IDs of the Nodes to return. The IDs of the Nodes to return.
@ -9246,7 +9266,7 @@ input TokenizedPaymentInput {
amount: Money! amount: Money!
""" """
A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. For more information, refer to [Idempotent requests](https://shopify.dev/concepts/about-apis/idempotent-requests).
""" """
idempotencyKey: String! idempotencyKey: String!
@ -9287,7 +9307,7 @@ input TokenizedPaymentInputV2 {
paymentAmount: MoneyInput! paymentAmount: MoneyInput!
""" """
A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. For more information, refer to [Idempotent requests](https://shopify.dev/concepts/about-apis/idempotent-requests).
""" """
idempotencyKey: String! idempotencyKey: String!
@ -9328,7 +9348,7 @@ input TokenizedPaymentInputV3 {
paymentAmount: MoneyInput! paymentAmount: MoneyInput!
""" """
A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. A unique client generated key used to avoid duplicate charges. When a duplicate payment is found, the original is returned instead of creating a new one. For more information, refer to [Idempotent requests](https://shopify.dev/concepts/about-apis/idempotent-requests).
""" """
idempotencyKey: String! idempotencyKey: String!
@ -9393,18 +9413,59 @@ type Transaction {
test: Boolean! test: Boolean!
} }
"""
The different kinds of order transactions.
"""
enum TransactionKind { enum TransactionKind {
"""
An authorization and capture performed together in a single step.
"""
SALE SALE
"""
A transfer of the money that was reserved during the authorization stage.
"""
CAPTURE CAPTURE
"""
An amount reserved against the cardholder's funding source.
Money does not change hands until the authorization is captured.
"""
AUTHORIZATION AUTHORIZATION
"""
An authorization for a payment taken with an EMV credit card reader.
"""
EMV_AUTHORIZATION EMV_AUTHORIZATION
"""
Money returned to the customer when they have paid too much.
"""
CHANGE CHANGE
} }
"""
Transaction statuses describe the status of a transaction.
"""
enum TransactionStatus { enum TransactionStatus {
"""
The transaction is pending.
"""
PENDING PENDING
"""
The transaction succeeded.
"""
SUCCESS SUCCESS
"""
The transaction failed.
"""
FAILURE FAILURE
"""
There was an error while processing the transaction.
"""
ERROR ERROR
} }

View File

@ -9,7 +9,9 @@ export type ShopifyCheckout = {
export type Cart = Core.Cart & { export type Cart = Core.Cart & {
lineItems: LineItem[] lineItems: LineItem[]
url?: String
} }
export interface LineItem extends Core.LineItem { export interface LineItem extends Core.LineItem {
options?: any[] options?: any[]
} }

View File

@ -27,12 +27,6 @@ export type CheckoutPayload =
| CheckoutQuery | CheckoutQuery
const checkoutToCart = (checkoutPayload?: Maybe<CheckoutPayload>): Cart => { const checkoutToCart = (checkoutPayload?: Maybe<CheckoutPayload>): Cart => {
if (!checkoutPayload) {
throw new CommerceError({
message: 'Missing checkout payload from response',
})
}
const checkout = checkoutPayload?.checkout const checkout = checkoutPayload?.checkout
throwUserErrors(checkoutPayload?.checkoutUserErrors) throwUserErrors(checkoutPayload?.checkoutUserErrors)

View File

@ -1,17 +1,19 @@
import { checkoutDetailsFragment } from '../queries/get-checkout-query' import { checkoutDetailsFragment } from '../queries/get-checkout-query'
const checkoutCreateMutation = /* GraphQL */ ` const checkoutCreateMutation = /* GraphQL */ `
mutation { mutation checkoutCreate($input: CheckoutCreateInput = {}) {
checkoutCreate(input: {}) { checkoutCreate(input: $input) {
checkoutUserErrors { checkoutUserErrors {
code code
field field
message message
} }
checkout { checkout {
...checkoutDetails
}
}
}
${checkoutDetailsFragment} ${checkoutDetailsFragment}
}
}
}
` `
export default checkoutCreateMutation export default checkoutCreateMutation

View File

@ -1,7 +1,10 @@
import { checkoutDetailsFragment } from '../queries/get-checkout-query' import { checkoutDetailsFragment } from '../queries/get-checkout-query'
const checkoutLineItemAddMutation = /* GraphQL */ ` const checkoutLineItemAddMutation = /* GraphQL */ `
mutation($checkoutId: ID!, $lineItems: [CheckoutLineItemInput!]!) { mutation checkoutLineItemAdd(
$checkoutId: ID!
$lineItems: [CheckoutLineItemInput!]!
) {
checkoutLineItemsAdd(checkoutId: $checkoutId, lineItems: $lineItems) { checkoutLineItemsAdd(checkoutId: $checkoutId, lineItems: $lineItems) {
checkoutUserErrors { checkoutUserErrors {
code code
@ -9,9 +12,11 @@ const checkoutLineItemAddMutation = /* GraphQL */ `
message message
} }
checkout { checkout {
...checkoutDetails
}
}
}
${checkoutDetailsFragment} ${checkoutDetailsFragment}
}
}
}
` `
export default checkoutLineItemAddMutation export default checkoutLineItemAddMutation

View File

@ -1,7 +1,7 @@
import { checkoutDetailsFragment } from '../queries/get-checkout-query' import { checkoutDetailsFragment } from '../queries/get-checkout-query'
const checkoutLineItemRemoveMutation = /* GraphQL */ ` const checkoutLineItemRemoveMutation = /* GraphQL */ `
mutation($checkoutId: ID!, $lineItemIds: [ID!]!) { mutation checkoutLineItemRemove($checkoutId: ID!, $lineItemIds: [ID!]!) {
checkoutLineItemsRemove( checkoutLineItemsRemove(
checkoutId: $checkoutId checkoutId: $checkoutId
lineItemIds: $lineItemIds lineItemIds: $lineItemIds
@ -12,9 +12,10 @@ const checkoutLineItemRemoveMutation = /* GraphQL */ `
message message
} }
checkout { checkout {
...checkoutDetails
}
}
}
${checkoutDetailsFragment} ${checkoutDetailsFragment}
}
}
}
` `
export default checkoutLineItemRemoveMutation export default checkoutLineItemRemoveMutation

View File

@ -1,7 +1,10 @@
import { checkoutDetailsFragment } from '../queries/get-checkout-query' import { checkoutDetailsFragment } from '../queries/get-checkout-query'
const checkoutLineItemUpdateMutation = /* GraphQL */ ` const checkoutLineItemUpdateMutation = /* GraphQL */ `
mutation($checkoutId: ID!, $lineItems: [CheckoutLineItemUpdateInput!]!) { mutation checkoutLineItemUpdate(
$checkoutId: ID!
$lineItems: [CheckoutLineItemUpdateInput!]!
) {
checkoutLineItemsUpdate(checkoutId: $checkoutId, lineItems: $lineItems) { checkoutLineItemsUpdate(checkoutId: $checkoutId, lineItems: $lineItems) {
checkoutUserErrors { checkoutUserErrors {
code code
@ -9,9 +12,11 @@ const checkoutLineItemUpdateMutation = /* GraphQL */ `
message message
} }
checkout { checkout {
...checkoutDetails
}
}
}
${checkoutDetailsFragment} ${checkoutDetailsFragment}
}
}
}
` `
export default checkoutLineItemUpdateMutation export default checkoutLineItemUpdateMutation

View File

@ -75,8 +75,7 @@ const normalizeProductVariants = ({ edges }: ProductVariantConnection) => {
) )
} }
export function normalizeProduct(productNode: ShopifyProduct): Product { export function normalizeProduct({
const {
id, id,
title: name, title: name,
vendor, vendor,
@ -87,10 +86,10 @@ export function normalizeProduct(productNode: ShopifyProduct): Product {
handle, handle,
priceRange, priceRange,
options, options,
metafields,
...rest ...rest
} = productNode }: ShopifyProduct): Product {
return {
const product = {
id, id,
name, name,
vendor, vendor,
@ -108,13 +107,12 @@ export function normalizeProduct(productNode: ShopifyProduct): Product {
...(descriptionHtml && { descriptionHtml }), ...(descriptionHtml && { descriptionHtml }),
...rest, ...rest,
} }
return product
} }
export function normalizeCart(checkout: Checkout): Cart { export function normalizeCart(checkout: Checkout): Cart {
return { return {
id: checkout.id, id: checkout.id,
url: checkout.webUrl,
customerId: '', customerId: '',
email: '', email: '',
createdAt: checkout.createdAt, createdAt: checkout.createdAt,
@ -131,7 +129,7 @@ export function normalizeCart(checkout: Checkout): Cart {
} }
function normalizeLineItem({ function normalizeLineItem({
node: { id, title, variant, quantity, ...rest }, node: { id, title, variant, quantity },
}: CheckoutLineItemEdge): LineItem { }: CheckoutLineItemEdge): LineItem {
return { return {
id, id,
@ -144,7 +142,7 @@ function normalizeLineItem({
sku: variant?.sku ?? '', sku: variant?.sku ?? '',
name: variant?.title!, name: variant?.title!,
image: { image: {
url: variant?.image?.originalSrc ?? '/product-img-placeholder.svg', url: variant?.image?.originalSrc || '/product-img-placeholder.svg',
}, },
requiresShipping: variant?.requiresShipping ?? false, requiresShipping: variant?.requiresShipping ?? false,
price: variant?.priceV2?.amount, price: variant?.priceV2?.amount,

View File

@ -1,9 +1,10 @@
export const productConnection = ` export const productConnectionFragment = /* GraphQL */ `
pageInfo { fragment productConnection on ProductConnection {
pageInfo {
hasNextPage hasNextPage
hasPreviousPage hasPreviousPage
} }
edges { edges {
node { node {
id id
title title
@ -30,17 +31,8 @@ edges {
} }
} }
} }
}` }
}
export const productsFragment = `
products(
first: $first
sortKey: $sortKey
reverse: $reverse
query: $query
) {
${productConnection}
}
` `
const getAllProductsQuery = /* GraphQL */ ` const getAllProductsQuery = /* GraphQL */ `
@ -50,7 +42,16 @@ const getAllProductsQuery = /* GraphQL */ `
$sortKey: ProductSortKeys = RELEVANCE $sortKey: ProductSortKeys = RELEVANCE
$reverse: Boolean = false $reverse: Boolean = false
) { ) {
${productsFragment} products(
first: $first
sortKey: $sortKey
reverse: $reverse
query: $query
) {
...productConnection
} }
}
${productConnectionFragment}
` `
export default getAllProductsQuery export default getAllProductsQuery

View File

@ -1,7 +1,8 @@
export const checkoutDetailsFragment = ` export const checkoutDetailsFragment = /* GraphQL */ `
fragment checkoutDetails on Checkout {
id id
webUrl webUrl
subtotalPriceV2{ subtotalPriceV2 {
amount amount
currencyCode currencyCode
} }
@ -35,11 +36,11 @@ export const checkoutDetailsFragment = `
width width
height height
} }
priceV2{ priceV2 {
amount amount
currencyCode currencyCode
} }
compareAtPriceV2{ compareAtPriceV2 {
amount amount
currencyCode currencyCode
} }
@ -51,15 +52,15 @@ export const checkoutDetailsFragment = `
} }
} }
} }
}
` `
const getCheckoutQuery = /* GraphQL */ ` const getCheckoutQuery = /* GraphQL */ `
query($checkoutId: ID!) { query getCheckout($checkoutId: ID!) {
node(id: $checkoutId) { node(id: $checkoutId) {
... on Checkout { ...checkoutDetails
}
}
${checkoutDetailsFragment} ${checkoutDetailsFragment}
}
}
}
` `
export default getCheckoutQuery export default getCheckoutQuery

View File

@ -1,4 +1,4 @@
import { productConnection } from './get-all-products-query' import { productConnectionFragment } from './get-all-products-query'
const getCollectionProductsQuery = /* GraphQL */ ` const getCollectionProductsQuery = /* GraphQL */ `
query getProductsFromCollection( query getProductsFromCollection(
@ -10,15 +10,12 @@ const getCollectionProductsQuery = /* GraphQL */ `
node(id: $categoryId) { node(id: $categoryId) {
id id
... on Collection { ... on Collection {
products( products(first: $first, sortKey: $sortKey, reverse: $reverse) {
first: $first ...productConnection
sortKey: $sortKey
reverse: $reverse
) {
${productConnection}
} }
} }
} }
} }
${productConnectionFragment}
` `
export default getCollectionProductsQuery export default getCollectionProductsQuery

View File

@ -1,5 +1,5 @@
export const getPageQuery = /* GraphQL */ ` export const getPageQuery = /* GraphQL */ `
query($id: ID!) { query getPage($id: ID!) {
node(id: $id) { node(id: $id) {
id id
... on Page { ... on Page {

View File

@ -9,7 +9,8 @@
"prettier-fix": "prettier --write .", "prettier-fix": "prettier --write .",
"find:unused": "next-unused", "find:unused": "next-unused",
"generate": "graphql-codegen", "generate": "graphql-codegen",
"generate:definitions": "node framework/bigcommerce/scripts/generate-definitions.js" "generate:definitions": "node framework/bigcommerce/scripts/generate-definitions.js",
"generate:shopify": "DOTENV_CONFIG_PATH=./.env.local graphql-codegen -r dotenv/config --config framework/shopify/codegen.json"
}, },
"sideEffects": false, "sideEffects": false,
"license": "MIT", "license": "MIT",