shopify_toolkit 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e5e83e71a4d7f6e6d0d8746e307076e7908f4e6c03d28820e99fde10557c6ba
4
- data.tar.gz: c9d9bce64d5af477e1e46a18dc18b175088fde22288c2d97e935c495f06beb42
3
+ metadata.gz: 457f7f3d4a71f0d16b2626673522a0c39fff7bf0cd0d77108dfad5be5ebed8dc
4
+ data.tar.gz: bbfc1ddfb371307e3eacfdcc24896628772886bb89e9333b5f0efab79dd34e42
5
5
  SHA512:
6
- metadata.gz: 7c39acdbf5c2b15e1b0c5276aefd65063857bae0da5431b9a929b55d2d8fe51517ba40c71ffe508ddda2100965c378f9a99c494de398afc906cfdb5674e65b7c
7
- data.tar.gz: cfa96c9301a1502eb02ba5fb5c854ffa8a5e72a4960910ba17cd82d475c9edeeab39989fe5d5f6c879b94b7f55835be6e334100cec24304ba1a56621e0fb5faa
6
+ metadata.gz: 2d81a0a15f9316488ffa6a7f56b5bbcab71196c8802568775d624802f9cba40ede8043d7e29e25008bc4e716bb01cdc5a299e4c542be92a53e1b681ef0c38b3e
7
+ data.tar.gz: 1896abe675d312bd57352cae7ca5e19a217055b551ed1ae992f1e453985c31361ea2d515333b6a5f129dbab4aab18ce0bb716faae49fc01615e76e6597bb7242
@@ -22,6 +22,12 @@ module ShopifyToolkit::MetafieldStatements
22
22
  def create_metafield(owner_type, key, type, namespace: :custom, name:, **options)
23
23
  ownerType = owner_type.to_s.singularize.upcase # Eg. "PRODUCT"
24
24
 
25
+ # Skip creation if metafield already exists
26
+ if get_metafield_gid(owner_type, key, namespace: namespace)
27
+ say "Metafield #{namespace}:#{key} already exists for #{owner_type}, skipping creation"
28
+ return
29
+ end
30
+
25
31
  # https://shopify.dev/docs/api/admin-graphql/2024-10/mutations/metafieldDefinitionCreate
26
32
  query =
27
33
  "# GraphQL
@@ -68,8 +74,7 @@ module ShopifyToolkit::MetafieldStatements
68
74
  .tap { handle_shopify_admin_client_errors(_1) }
69
75
  .body
70
76
 
71
- result.dig("data", "metafieldDefinitions", "nodes", 0, "id") or
72
- raise "Metafield not found for #{owner_type}##{namespace}:#{key}"
77
+ result.dig("data", "metafieldDefinitions", "nodes", 0, "id")
73
78
  end
74
79
 
75
80
  log_time \
@@ -79,6 +84,11 @@ module ShopifyToolkit::MetafieldStatements
79
84
  "For reserved namespaces, you must delete all associated metafields (delete_associated_metafields: true)"
80
85
  end
81
86
 
87
+ unless get_metafield_gid(owner_type, key, namespace: namespace)
88
+ say "Metafield #{namespace}:#{key} not found for #{owner_type}, skipping deletion"
89
+ return
90
+ end
91
+
82
92
  shopify_admin_client
83
93
  .query(
84
94
  # Documentation: https://shopify.dev/docs/api/admin-graphql/2024-10/mutations/metafieldDefinitionDelete
@@ -104,6 +114,11 @@ module ShopifyToolkit::MetafieldStatements
104
114
 
105
115
  log_time \
106
116
  def update_metafield(owner_type, key, namespace: :custom, **options)
117
+ unless get_metafield_gid(owner_type, key, namespace: namespace)
118
+ say "Metafield #{namespace}:#{key} not found for #{owner_type}, skipping update"
119
+ return
120
+ end
121
+
107
122
  shopify_admin_client
108
123
  .query(
109
124
  # Documentation: https://shopify.dev/docs/api/admin-graphql/2024-10/mutations/metafieldDefinitionUpdate
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ShopifyToolkit
4
- VERSION = "0.3.4"
4
+ VERSION = "0.3.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elia Schito
8
8
  - Nebulab Team
9
+ autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2025-04-18 00:00:00.000000000 Z
12
+ date: 2025-04-24 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: railties
@@ -94,6 +95,7 @@ dependencies:
94
95
  - - ">="
95
96
  - !ruby/object:Gem::Version
96
97
  version: '14.8'
98
+ description:
97
99
  email:
98
100
  - elia@schito.me
99
101
  executables:
@@ -123,6 +125,7 @@ metadata:
123
125
  homepage_uri: https://github.com/nebulab/shopify_toolkit?tab=readme-ov-file#readme
124
126
  source_code_uri: https://github.com/nebulab/shopify_toolkit
125
127
  changelog_uri: https://github.com/nebulab/shopify_toolkit/releases
128
+ post_install_message:
126
129
  rdoc_options: []
127
130
  require_paths:
128
131
  - lib
@@ -137,7 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
140
  - !ruby/object:Gem::Version
138
141
  version: '0'
139
142
  requirements: []
140
- rubygems_version: 3.6.3
143
+ rubygems_version: 3.5.3
144
+ signing_key:
141
145
  specification_version: 4
142
146
  summary: A collection of tools for dealing with Shopify apps.
143
147
  test_files: []