Class: EPlat::Shopify::GraphQL::V202510::Input::Product::Variant

Inherits:
EPlat::Shopify::GraphQL::V202510::Input
  • Object
show all
Defined in:
lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2025_10/input/product/variant.rb

Constant Summary collapse

USES_ELEMENT_NAME_AS_INPUT_ROOT_KEY =
false
SUPPORTED_FIELDS =
%w[
  barcode
  compareAtPrice
  id
  inventoryItem
  inventoryPolicy
  inventoryQuantities
  mediaSrc
  metafields
  optionValues
  price
  taxable
].freeze
SUPPORTED_NAMED_ARGUMENT_FIELDS =
{
  product_id: %w[
    productId
  ],
  variant: %w[
    barcode
    compareAtPrice
    id
    inventoryItem
    inventoryPolicy
    inventoryQuantities
    mediaSrc
    metafields
    optionValues
    price
    taxable
  ],
  variants: %w[
    barcode
    compareAtPrice
    id
    inventoryItem
    inventoryPolicy
    inventoryQuantities
    mediaSrc
    metafields
    optionValues
    price
    taxable
  ],
  inventory_item: %w[
    cost
    countryCodeOfOrigin
    countryHarmonizedSystemCodes
    harmonizedSystemCode
    measurement
    provinceCodeOfOrigin
    requiresShipping
    sku
    tracked
  ],
  option_values: %w[
    optionId
    name
    linkedMetafieldValue
    optionId
    optionName
  ]
}.with_indifferent_access.freeze

Class Method Summary collapse

Class Method Details

.mutation_input(resource, action) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2025_10/input/product/variant.rb', line 69

def self.mutation_input(resource, action)
  case action.to_sym
  when :delete
    new( 
      variantsIds: [resource.formatted_id], 
      product_id: EPlat::Product.formatted_id(resource.product_id)
    )
  else
    new(
      variants: [
        resource.class.mapping.via_native_attributes_where_possible(
          resource.class.remove_root_from(resource.as_json)
        )
      ],
      product_id: EPlat::Product.formatted_id(resource.product_id)
    )
  end.query_input
end