Skip to content

Commit 744c6e5

Browse files
Add graphql_points_limit to CurrentShop (#68)
1 parent 2209966 commit 744c6e5

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

app/graphql/shopify_graphql/current_shop.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class CurrentShop
7272
def call(with_locales: false)
7373
query = prepare_query(QUERY, with_locales: with_locales)
7474
response = execute(query)
75-
parse_data(response.data, with_locales: with_locales)
75+
parse_data(response, with_locales: with_locales)
7676
end
7777

7878
private
@@ -101,10 +101,11 @@ def prepare_query(query, with_locales:)
101101
query
102102
end
103103

104-
def parse_data(data, with_locales: false)
104+
def parse_data(response, with_locales: false)
105+
data = response.data
105106
plan_display_name = ShopifyGraphql.normalize_plan_display_name(data.shop.plan.displayName)
106107
plan_name = ShopifyGraphql::DISPLAY_NAME_TO_PLAN[plan_display_name]
107-
response = OpenStruct.new(
108+
shop_data = OpenStruct.new(
108109
id: data.shop.id.split("/").last.to_i,
109110
name: data.shop.name,
110111
email: data.shop.email,
@@ -145,13 +146,14 @@ def parse_data(data, with_locales: false)
145146
marketing_sms_consent_enabled_at_checkout: data.shop.marketingSmsConsentEnabledAtCheckout,
146147
max_product_options: data.shop.resourceLimits.maxProductOptions,
147148
max_product_variants: data.shop.resourceLimits.maxProductVariants,
148-
unified_markets: !!data.shop&.features&.unifiedMarkets
149+
unified_markets: !!data.shop&.features&.unifiedMarkets,
150+
graphql_points_limit: response.points_limit
149151
)
150152
if with_locales
151-
response.primary_locale = data.shopLocales.find(&:primary).locale
152-
response.shop_locales = data.shopLocales.map(&:locale)
153+
shop_data.primary_locale = data.shopLocales.find(&:primary).locale
154+
shop_data.shop_locales = data.shopLocales.map(&:locale)
153155
end
154-
response
156+
shop_data
155157
end
156158
end
157159
end

test/graphql/shopify_graphql/current_shop_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class CurrentShopTest < ActiveSupport::TestCase
1212
assert_equal "example.myshopify.com", shop.myshopify_domain
1313
assert_equal 3, shop.max_product_options
1414
assert_equal 100, shop.max_product_variants
15+
assert_equal 2000, shop.graphql_points_limit
1516
end
1617

1718
test "returns shop with shop locales" do

0 commit comments

Comments
 (0)