From da2f641bbbda272d3b2ae78abf71f616db212e23 Mon Sep 17 00:00:00 2001 From: Bret Little Date: Fri, 20 Oct 2023 14:52:53 -0400 Subject: [PATCH] Fix the starter template blog route to include a required `startCursor` in the GraphQL query. Resolves #1337 --- .changeset/itchy-panthers-hear.md | 6 ++++++ .../routes/($locale).collections.$collectionHandle.tsx | 1 - templates/demo-store/storefrontapi.generated.d.ts | 2 +- templates/skeleton/app/routes/account.orders._index.tsx | 1 + .../skeleton/app/routes/blogs.$blogHandle._index.tsx | 1 + templates/skeleton/storefrontapi.generated.d.ts | 8 ++++---- 6 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 .changeset/itchy-panthers-hear.md diff --git a/.changeset/itchy-panthers-hear.md b/.changeset/itchy-panthers-hear.md new file mode 100644 index 0000000000..b1a6d1faba --- /dev/null +++ b/.changeset/itchy-panthers-hear.md @@ -0,0 +1,6 @@ +--- +'demo-store': patch +'@shopify/create-hydrogen': patch +--- + +Fix the starter template blog route to include a required `startCursor` in the GraphQL query. diff --git a/templates/demo-store/app/routes/($locale).collections.$collectionHandle.tsx b/templates/demo-store/app/routes/($locale).collections.$collectionHandle.tsx index fbc017a450..69c835700f 100644 --- a/templates/demo-store/app/routes/($locale).collections.$collectionHandle.tsx +++ b/templates/demo-store/app/routes/($locale).collections.$collectionHandle.tsx @@ -297,7 +297,6 @@ const COLLECTION_QUERY = `#graphql pageInfo { hasPreviousPage hasNextPage - hasNextPage endCursor startCursor } diff --git a/templates/demo-store/storefrontapi.generated.d.ts b/templates/demo-store/storefrontapi.generated.d.ts index 3a91986948..3b780642cd 100644 --- a/templates/demo-store/storefrontapi.generated.d.ts +++ b/templates/demo-store/storefrontapi.generated.d.ts @@ -1706,7 +1706,7 @@ interface GeneratedQueryTypes { return: ApiAllProductsQuery; variables: ApiAllProductsQueryVariables; }; - '#graphql\n query CollectionDetails(\n $handle: String!\n $country: CountryCode\n $language: LanguageCode\n $filters: [ProductFilter!]\n $sortKey: ProductCollectionSortKeys!\n $reverse: Boolean\n $first: Int\n $last: Int\n $startCursor: String\n $endCursor: String\n ) @inContext(country: $country, language: $language) {\n collection(handle: $handle) {\n id\n handle\n title\n description\n seo {\n description\n title\n }\n image {\n id\n url\n width\n height\n altText\n }\n products(\n first: $first,\n last: $last,\n before: $startCursor,\n after: $endCursor,\n filters: $filters,\n sortKey: $sortKey,\n reverse: $reverse\n ) {\n filters {\n id\n label\n type\n values {\n id\n label\n count\n input\n }\n }\n nodes {\n ...ProductCard\n }\n pageInfo {\n hasPreviousPage\n hasNextPage\n hasNextPage\n endCursor\n startCursor\n }\n }\n }\n collections(first: 100) {\n edges {\n node {\n title\n handle\n }\n }\n }\n }\n #graphql\n fragment ProductCard on Product {\n id\n title\n publishedAt\n handle\n vendor\n variants(first: 1) {\n nodes {\n id\n availableForSale\n image {\n url\n altText\n width\n height\n }\n price {\n amount\n currencyCode\n }\n compareAtPrice {\n amount\n currencyCode\n }\n selectedOptions {\n name\n value\n }\n product {\n handle\n title\n }\n }\n }\n }\n\n': { + '#graphql\n query CollectionDetails(\n $handle: String!\n $country: CountryCode\n $language: LanguageCode\n $filters: [ProductFilter!]\n $sortKey: ProductCollectionSortKeys!\n $reverse: Boolean\n $first: Int\n $last: Int\n $startCursor: String\n $endCursor: String\n ) @inContext(country: $country, language: $language) {\n collection(handle: $handle) {\n id\n handle\n title\n description\n seo {\n description\n title\n }\n image {\n id\n url\n width\n height\n altText\n }\n products(\n first: $first,\n last: $last,\n before: $startCursor,\n after: $endCursor,\n filters: $filters,\n sortKey: $sortKey,\n reverse: $reverse\n ) {\n filters {\n id\n label\n type\n values {\n id\n label\n count\n input\n }\n }\n nodes {\n ...ProductCard\n }\n pageInfo {\n hasPreviousPage\n hasNextPage\n endCursor\n startCursor\n }\n }\n }\n collections(first: 100) {\n edges {\n node {\n title\n handle\n }\n }\n }\n }\n #graphql\n fragment ProductCard on Product {\n id\n title\n publishedAt\n handle\n vendor\n variants(first: 1) {\n nodes {\n id\n availableForSale\n image {\n url\n altText\n width\n height\n }\n price {\n amount\n currencyCode\n }\n compareAtPrice {\n amount\n currencyCode\n }\n selectedOptions {\n name\n value\n }\n product {\n handle\n title\n }\n }\n }\n }\n\n': { return: CollectionDetailsQuery; variables: CollectionDetailsQueryVariables; }; diff --git a/templates/skeleton/app/routes/account.orders._index.tsx b/templates/skeleton/app/routes/account.orders._index.tsx index 59a92d0b63..588a43ced6 100644 --- a/templates/skeleton/app/routes/account.orders._index.tsx +++ b/templates/skeleton/app/routes/account.orders._index.tsx @@ -166,6 +166,7 @@ export const CUSTOMER_FRAGMENT = `#graphql hasNextPage hasNextPage endCursor + startCursor } } } diff --git a/templates/skeleton/app/routes/blogs.$blogHandle._index.tsx b/templates/skeleton/app/routes/blogs.$blogHandle._index.tsx index 187509d6d4..a607aacbf3 100644 --- a/templates/skeleton/app/routes/blogs.$blogHandle._index.tsx +++ b/templates/skeleton/app/routes/blogs.$blogHandle._index.tsx @@ -133,6 +133,7 @@ const BLOGS_QUERY = `#graphql hasNextPage hasNextPage endCursor + startCursor } } diff --git a/templates/skeleton/storefrontapi.generated.d.ts b/templates/skeleton/storefrontapi.generated.d.ts index d0e1a86d8a..1d515b6fa2 100644 --- a/templates/skeleton/storefrontapi.generated.d.ts +++ b/templates/skeleton/storefrontapi.generated.d.ts @@ -637,7 +637,7 @@ export type CustomerOrdersFragment = Pick< >; pageInfo: Pick< StorefrontAPI.PageInfo, - 'hasPreviousPage' | 'hasNextPage' | 'endCursor' + 'hasPreviousPage' | 'hasNextPage' | 'endCursor' | 'startCursor' >; }; }; @@ -689,7 +689,7 @@ export type CustomerOrdersQuery = { >; pageInfo: Pick< StorefrontAPI.PageInfo, - 'hasPreviousPage' | 'hasNextPage' | 'endCursor' + 'hasPreviousPage' | 'hasNextPage' | 'endCursor' | 'startCursor' >; }; } @@ -1113,7 +1113,7 @@ export type BlogQuery = { >; pageInfo: Pick< StorefrontAPI.PageInfo, - 'hasPreviousPage' | 'hasNextPage' | 'endCursor' + 'hasPreviousPage' | 'hasNextPage' | 'endCursor' | 'startCursor' >; }; } @@ -1811,7 +1811,7 @@ interface GeneratedQueryTypes { return: ArticleQuery; variables: ArticleQueryVariables; }; - '#graphql\n query Blog(\n $language: LanguageCode\n $blogHandle: String!\n $first: Int\n $last: Int\n $startCursor: String\n $endCursor: String\n ) @inContext(language: $language) {\n blog(handle: $blogHandle) {\n title\n seo {\n title\n description\n }\n articles(\n first: $first,\n last: $last,\n before: $startCursor,\n after: $endCursor\n ) {\n nodes {\n ...ArticleItem\n }\n pageInfo {\n hasPreviousPage\n hasNextPage\n hasNextPage\n endCursor\n }\n\n }\n }\n }\n fragment ArticleItem on Article {\n author: authorV2 {\n name\n }\n contentHtml\n handle\n id\n image {\n id\n altText\n url\n width\n height\n }\n publishedAt\n title\n blog {\n handle\n }\n }\n': { + '#graphql\n query Blog(\n $language: LanguageCode\n $blogHandle: String!\n $first: Int\n $last: Int\n $startCursor: String\n $endCursor: String\n ) @inContext(language: $language) {\n blog(handle: $blogHandle) {\n title\n seo {\n title\n description\n }\n articles(\n first: $first,\n last: $last,\n before: $startCursor,\n after: $endCursor\n ) {\n nodes {\n ...ArticleItem\n }\n pageInfo {\n hasPreviousPage\n hasNextPage\n hasNextPage\n endCursor\n startCursor\n }\n\n }\n }\n }\n fragment ArticleItem on Article {\n author: authorV2 {\n name\n }\n contentHtml\n handle\n id\n image {\n id\n altText\n url\n width\n height\n }\n publishedAt\n title\n blog {\n handle\n }\n }\n': { return: BlogQuery; variables: BlogQueryVariables; };