Skip to content

Commit

Permalink
chore: graphql query cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyagabriel committed Oct 3, 2024
1 parent ea85954 commit 63ffcb6
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 106 deletions.
2 changes: 1 addition & 1 deletion app/data/queries/article.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const ARTICLE_QUERY = `#graphql
}
sections(first: 25, after: $cursor) {
nodes {
...section
...SectionFragment
}
pageInfo {
hasNextPage
Expand Down
2 changes: 1 addition & 1 deletion app/data/queries/blog.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const BLOG_QUERY = `#graphql
}
sections(first: 25) {
nodes {
...section
...SectionFragment
}
pageInfo {
hasNextPage
Expand Down
2 changes: 1 addition & 1 deletion app/data/queries/cart.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const CART_LINE_FRAGMENT = `#graphql
}
}
options {
...option
...OptionFragment
}
images(first: 20) {
nodes {
Expand Down
12 changes: 6 additions & 6 deletions app/data/queries/collection.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const COLLECTION_PAGE_QUERY = `#graphql
status
sections(first: 25) {
nodes {
...section
...SectionFragment
}
pageInfo {
hasNextPage
Expand Down Expand Up @@ -71,7 +71,7 @@ export const CMS_COLLECTIONS_QUERY = `#graphql
// Docs: https://shopify.dev/docs/api/storefront/latest/queries/collection

const COLLECTION_FRAGMENT = `#graphql
fragment collectionFragment on Collection {
fragment CollectionFragment on Collection {
id
title
description
Expand Down Expand Up @@ -126,7 +126,7 @@ const COLLECTION_FRAGMENT = `#graphql
}
nodes {
... on Product {
...productItemFragment
...ProductItemFragment
}
}
}
Expand All @@ -139,7 +139,7 @@ const COLLECTION_FRAGMENT = `#graphql
` as const;

export const COLLECTION_QUERY = `#graphql
query CollectionDetails(
query Collection(
$handle: String!,
$country: CountryCode,
$language: LanguageCode
Expand All @@ -153,15 +153,15 @@ export const COLLECTION_QUERY = `#graphql
) @inContext(country: $country, language: $language) {
collection(handle: $handle) {
... on Collection {
...collectionFragment
...CollectionFragment
}
}
}
${COLLECTION_FRAGMENT}
` as const;

export const COLLECTION_FILTERS_QUERY = `#graphql
query CollectionDetails(
query CollectionFilters(
$handle: String!,
$country: CountryCode,
$language: LanguageCode
Expand Down
2 changes: 1 addition & 1 deletion app/data/queries/pack.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const PRODUCT_GROUPINGS_QUERY = `#graphql
` as const;

export const SECTION_FRAGMENT = `#graphql
fragment section on Section {
fragment SectionFragment on Section {
id
title
status
Expand Down
2 changes: 1 addition & 1 deletion app/data/queries/page.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const PAGE_QUERY = `#graphql
}
sections(first: 25, after: $cursor) {
nodes {
...section
...SectionFragment
}
pageInfo {
hasNextPage
Expand Down
100 changes: 25 additions & 75 deletions app/data/queries/product.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const PRODUCT_PAGE_QUERY = `#graphql
status
sections(first: 25) {
nodes {
...section
...SectionFragment
}
pageInfo {
hasNextPage
Expand Down Expand Up @@ -78,7 +78,7 @@ export const CMS_PRODUCTS_QUERY = `#graphql
// Docs: https://shopify.dev/docs/api/storefront/latest/queries/product

export const OPTION_FRAGMENT = `#graphql
fragment option on ProductOption {
fragment OptionFragment on ProductOption {
id
name
optionValues {
Expand All @@ -104,7 +104,7 @@ export const OPTION_FRAGMENT = `#graphql
`;

export const METAFIELD_FRAGMENT = `#graphql
fragment metafield on Metafield {
fragment MetafieldFragment on Metafield {
createdAt
description
id
Expand All @@ -117,7 +117,7 @@ fragment metafield on Metafield {
`;

export const VARIANT_FRAGMENT = `#graphql
fragment variantFragment on ProductVariant {
fragment VariantFragment on ProductVariant {
id
title
availableForSale
Expand All @@ -139,7 +139,7 @@ export const VARIANT_FRAGMENT = `#graphql
edges {
node {
... on SellingPlanAllocation {
...sellingPlanAllocation
...SellingPlanAllocationFragment
}
}
}
Expand All @@ -164,7 +164,7 @@ export const VARIANT_FRAGMENT = `#graphql
` as const;

export const PRODUCT_FRAGMENT = `#graphql
fragment productFragment on Product {
fragment ProductFragment on Product {
id
title
handle
Expand Down Expand Up @@ -251,26 +251,26 @@ export const PRODUCT_FRAGMENT = `#graphql
}
}
options {
...option
...OptionFragment
}
selectedVariant: variantBySelectedOptions(selectedOptions: $selectedOptions) {
... on ProductVariant {
...variantFragment
...VariantFragment
}
}
sellingPlanGroups(first: 10) {
edges {
node {
... on SellingPlanGroup {
...sellingPlanGroup
...SellingPlanGroupFragment
}
}
}
}
variants(first: 250) {
nodes {
... on ProductVariant {
...variantFragment
...VariantFragment
}
}
}
Expand All @@ -285,7 +285,7 @@ export const PRODUCT_FRAGMENT = `#graphql
` as const;

export const PRODUCT_ITEM_FRAGMENT = `#graphql
fragment productItemFragment on Product {
fragment ProductItemFragment on Product {
id
title
handle
Expand Down Expand Up @@ -340,21 +340,21 @@ export const PRODUCT_ITEM_FRAGMENT = `#graphql
}
}
options {
...option
...OptionFragment
}
sellingPlanGroups(first: 10) {
edges {
node {
... on SellingPlanGroup {
...sellingPlanGroup
...SellingPlanGroupFragment
}
}
}
}
variants(first: 100) {
nodes {
... on ProductVariant {
...variantFragment
...VariantFragment
}
}
}
Expand All @@ -365,38 +365,38 @@ export const PRODUCT_ITEM_FRAGMENT = `#graphql
` as const;

export const PRODUCT_QUERY = `#graphql
query product(
query Product(
$handle: String!
$country: CountryCode
$language: LanguageCode
$selectedOptions: [SelectedOptionInput!]!
) @inContext(country: $country, language: $language) {
product(handle: $handle) {
... on Product {
...productFragment
...ProductFragment
}
}
}
${PRODUCT_FRAGMENT}
` as const;

export const PRODUCT_ITEM_QUERY = `#graphql
query product(
query ProductItem(
$handle: String!
$country: CountryCode
$language: LanguageCode
) @inContext(country: $country, language: $language) {
product(handle: $handle) {
... on Product {
...productItemFragment
...ProductItemFragment
}
}
}
${PRODUCT_ITEM_FRAGMENT}
` as const;

export const PRODUCT_METAFIELDS_QUERY = `#graphql
query product(
query ProductMetafields(
$handle: String!
$key: String!
$namespace: String
Expand All @@ -405,63 +405,13 @@ export const PRODUCT_METAFIELDS_QUERY = `#graphql
) @inContext(country: $country, language: $language) {
product(handle: $handle) {
metafields(identifiers: {key: $key, namespace: $namespace}) {
...metafield
...MetafieldFragment
}
}
}
${METAFIELD_FRAGMENT}
` as const;

export const GROUPING_PRODUCT_QUERY = `#graphql
query product(
$handle: String!
$country: CountryCode
$language: LanguageCode
) @inContext(country: $country, language: $language) {
product(handle: $handle) {
id
title
handle
productType
options {
...option
}
variants(first: 100) {
nodes {
id
title
availableForSale
sku
image {
altText
height
id
url
width
}
price {
currencyCode
amount
}
compareAtPrice {
currencyCode
amount
}
selectedOptions {
name
value
}
product {
handle
id
}
}
}
}
}
${OPTION_FRAGMENT}
` as const;

export const PRODUCTS_QUERY = `#graphql
query Products(
$query: String
Expand All @@ -481,7 +431,7 @@ export const PRODUCTS_QUERY = `#graphql
}
nodes {
... on Product {
...productItemFragment
...ProductItemFragment
}
}
}
Expand All @@ -490,7 +440,7 @@ export const PRODUCTS_QUERY = `#graphql
` as const;

export const PRODUCT_FEED_QUERY = `#graphql
query Products(
query ProductsFeed(
$first: Int!
$cursor: String
$country: CountryCode
Expand All @@ -503,7 +453,7 @@ export const PRODUCT_FEED_QUERY = `#graphql
}
nodes {
... on Product {
...productItemFragment
...ProductItemFragment
}
}
}
Expand All @@ -512,15 +462,15 @@ export const PRODUCT_FEED_QUERY = `#graphql
` as const;

export const PRODUCT_RECOMMENDATIONS_QUERY = `#graphql
query productRecommendations(
query ProductRecommendations(
$productId: ID!
$intent: ProductRecommendationIntent
$country: CountryCode
$language: LanguageCode
) @inContext(country: $country, language: $language) {
productRecommendations(productId: $productId, intent: $intent) {
... on Product {
...productItemFragment
...ProductItemFragment
}
}
}
Expand Down
Loading

0 comments on commit 63ffcb6

Please sign in to comment.