23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'app/graphql/shopify_graphql/upsert_private_metafield.rb', line 23
def call(namespace:, key:, value:, owner: nil)
input = {namespace: namespace, key: key}
input[:owner] = owner if owner
case value
when Hash, Array
value = value.to_json
value_type = "JSON_STRING"
when Integer
value_type = "INTEGER"
else
value = value.to_s
value_type = "STRING"
end
input[:valueInput] = {value: value, valueType: value_type}
response = execute(MUTATION, input: input)
handle_user_errors(response.data.privateMetafieldUpsert)
response.data = parse_data(response.data)
response
end
|