Skip to content

Commit 3e912e5

Browse files
Add #unified_markets flag to CurrentShop (#65)
1 parent 2244240 commit 3e912e5

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

app/graphql/shopify_graphql/current_shop.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class CurrentShop
5252
maxProductOptions
5353
maxProductVariants
5454
}
55+
#FEATURES#
5556
}
5657
#LOCALES_SUBQUERY#
5758
}
@@ -62,6 +63,11 @@ class CurrentShop
6263
primary
6364
}
6465
GRAPHQL
66+
FEATURES_SUBQUERY = <<~GRAPHQL
67+
features {
68+
unifiedMarkets
69+
}
70+
GRAPHQL
6571

6672
def call(with_locales: false)
6773
query = prepare_query(QUERY, with_locales: with_locales)
@@ -87,6 +93,11 @@ def prepare_query(query, with_locales:)
8793
query.gsub!("#UPDATED_AT#", "updatedAt")
8894
query.gsub!("#SMS_CONSENT#", "marketingSmsConsentEnabledAtCheckout")
8995
end
96+
if ShopifyAPI::Context.api_version.in?(%w[2024-01 2024-04 2024-07 2024-10 2025-01])
97+
query.gsub!("#FEATURES#", "")
98+
else
99+
query.gsub!("#FEATURES#", FEATURES_SUBQUERY)
100+
end
90101
query
91102
end
92103

@@ -133,7 +144,8 @@ def parse_data(data, with_locales: false)
133144
enabled_presentment_currencies: data.shop.enabledPresentmentCurrencies,
134145
marketing_sms_consent_enabled_at_checkout: data.shop.marketingSmsConsentEnabledAtCheckout,
135146
max_product_options: data.shop.resourceLimits.maxProductOptions,
136-
max_product_variants: data.shop.resourceLimits.maxProductVariants
147+
max_product_variants: data.shop.resourceLimits.maxProductVariants,
148+
unified_markets: !!data.shop&.features&.unifiedMarkets
137149
)
138150
if with_locales
139151
response.primary_locale = data.shopLocales.find(&:primary).locale

0 commit comments

Comments
 (0)