e_plat 0.6.0 → 0.7.0

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +84 -54
  3. data/lib/e_plat/client/default_request_args.rb +1 -1
  4. data/lib/e_plat/client.rb +34 -8
  5. data/lib/e_plat/mapping/bigcommerce/v_3/product/option.rb +58 -0
  6. data/lib/e_plat/mapping/bigcommerce/v_3/product/variant/option_value.rb +42 -0
  7. data/lib/e_plat/mapping/shopify/v_2024_07/metafield.rb +26 -0
  8. data/lib/e_plat/mapping/shopify/v_2024_07/order/billing_address.rb +14 -0
  9. data/lib/e_plat/mapping/shopify/v_2024_07/order/shipping_address.rb +30 -0
  10. data/lib/e_plat/mapping/shopify/v_2024_07/order.rb +26 -0
  11. data/lib/e_plat/mapping/shopify/v_2024_07/product/image.rb +52 -0
  12. data/lib/e_plat/mapping/shopify/v_2024_07/product/option.rb +45 -0
  13. data/lib/e_plat/mapping/shopify/v_2024_07/product/variant/option_value.rb +58 -0
  14. data/lib/e_plat/mapping/shopify/v_2024_07/product/variant.rb +180 -0
  15. data/lib/e_plat/mapping/shopify/v_2024_07/product.rb +100 -0
  16. data/lib/e_plat/mapping/shopify/v_2024_07/script_tag.rb +26 -0
  17. data/lib/e_plat/mapping/shopify/v_2024_07/shop.rb +26 -0
  18. data/lib/e_plat/mapping/shopify/v_2024_07/webhook.rb +29 -0
  19. data/lib/e_plat/mapping/virtual_collection/shopify/product/variant/option_value.rb +272 -0
  20. data/lib/e_plat/resource/base.rb +24 -2
  21. data/lib/e_plat/resource/collection.rb +45 -16
  22. data/lib/e_plat/resource/concerns/aliases.rb +39 -19
  23. data/lib/e_plat/resource/concerns/dirty.rb +12 -8
  24. data/lib/e_plat/resource/concerns/graph_q_lable.rb +253 -0
  25. data/lib/e_plat/resource/concerns/overwrite_instance_methods.rb +4 -4
  26. data/lib/e_plat/resource/concerns/overwrite_request_methods.rb +1 -1
  27. data/lib/e_plat/resource/countable.rb +37 -10
  28. data/lib/e_plat/resource/platform_specific/bigcommerce/product/variant/option_value.rb +2 -0
  29. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/input/product/variant.rb +47 -0
  30. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/input/product/variants_bulk.rb +47 -0
  31. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/input/product.rb +23 -0
  32. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/input.rb +98 -0
  33. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/mutation/product/variant.rb +78 -0
  34. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/mutation/product.rb +55 -0
  35. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/mutation.rb +5 -0
  36. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/query/product/variant.rb +44 -0
  37. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/query/product.rb +58 -0
  38. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/query.rb +5 -0
  39. data/lib/e_plat/resource/platform_specific/shopify/product/image.rb +13 -1
  40. data/lib/e_plat/resource/platform_specific/shopify/product/option.rb +13 -1
  41. data/lib/e_plat/resource/platform_specific/shopify/product/variant/option_value.rb +14 -0
  42. data/lib/e_plat/resource/platform_specific/shopify/product/variant.rb +65 -1
  43. data/lib/e_plat/resource/platform_specific/shopify/product.rb +77 -2
  44. data/lib/e_plat/resource/product/image.rb +8 -5
  45. data/lib/e_plat/resource/product/option.rb +2 -3
  46. data/lib/e_plat/resource/product/variant/option_value.rb +17 -0
  47. data/lib/e_plat/resource/product/variant.rb +4 -10
  48. data/lib/e_plat/resource/product.rb +23 -11
  49. data/lib/e_plat/session.rb +3 -2
  50. data/lib/e_plat/type_coercer.rb +3 -1
  51. data/lib/e_plat/version.rb +1 -1
  52. data/lib/e_plat.rb +12 -3
  53. data/lib/hash.rb +39 -0
  54. metadata +130 -27
@@ -0,0 +1,47 @@
1
+ class EPlat::Shopify::GraphQL::V202407::Input::Product::VariantsBulk < EPlat::Shopify::GraphQL::V202407::Input
2
+ SUPPORTED_FIELDS = %w[
3
+ barcode
4
+ compareAtPrice
5
+ id
6
+ inventoryItem
7
+ inventoryPolicy
8
+ inventoryQuantities
9
+ mediaId
10
+ mediaSrc
11
+ metafields
12
+ optionValues
13
+ price
14
+ taxCode
15
+ taxable
16
+ ].freeze
17
+
18
+ SUPPORTED_NAMED_ARGUMENT_FIELDS = {
19
+ # product_id: id,
20
+ variants: %w[
21
+ barcode
22
+ compareAtPrice
23
+ id
24
+ inventoryItem
25
+ inventoryPolicy
26
+ inventoryQuantities
27
+ mediaId
28
+ mediaSrc
29
+ metafields
30
+ optionValues
31
+ price
32
+ taxCode
33
+ taxable
34
+ ],
35
+ inventory_item: %w[
36
+ cost
37
+ countryCodeOfOrigin
38
+ countryHarmonizedSystemCodes
39
+ harmonizedSystemCode
40
+ measurement
41
+ provinceCodeOfOrigin
42
+ requiresShipping
43
+ sku
44
+ tracked
45
+ ]
46
+ }.with_indifferent_access.freeze
47
+ end
@@ -0,0 +1,23 @@
1
+ class EPlat::Shopify::GraphQL::V202407::Input::Product < EPlat::Shopify::GraphQL::V202407::Input
2
+ SUPPORTED_FIELDS = %w[
3
+ title
4
+ descriptionHtml
5
+ productType
6
+ vendor
7
+ tags
8
+ collectionsToJoin
9
+ collectionsToLeave
10
+ metafields
11
+ productOptions
12
+ customProductType
13
+ templateSuffix
14
+ redirectNewHandle
15
+ requiresSellingPlan
16
+ giftCard
17
+ giftCardTemplateSuffix
18
+ seo
19
+ status
20
+ id
21
+ handle
22
+ ].freeze
23
+ end
@@ -0,0 +1,98 @@
1
+ class EPlat::Shopify::GraphQL::V202407::Input
2
+ attr_accessor :input, :named_arguments
3
+
4
+ SUPPORTED_FIELDS = []
5
+ SUPPORTED_NAMED_ARGUMENT_FIELDS = {}
6
+
7
+ def initialize(input = {}, **named_arguments)
8
+ @input = input.deep_transform_keys { |key| key.to_s.camelize(:lower) }
9
+ @named_arguments = named_arguments.deep_transform_keys { |key| key.to_s.camelize(:lower) }
10
+ end
11
+
12
+ def to_graphql_args
13
+ args = named_arguments.present? ? named_arguments_with_allowed_fields(named_arguments) : { input: allowed_fields }
14
+ format_graphql_args(args)
15
+ end
16
+
17
+ protected
18
+
19
+ def allowed_fields
20
+ fields_hash = input.slice(*self.class::SUPPORTED_FIELDS)
21
+
22
+ fields_hash.map do |key, value|
23
+ if value.is_a?(Hash) && child_allowed_fields = self.class::SUPPORTED_NAMED_ARGUMENT_FIELDS[key] || self.class::SUPPORTED_NAMED_ARGUMENT_FIELDS[key&.underscore]
24
+ [key, value.slice(*child_allowed_fields)]
25
+ else
26
+ [key, value]
27
+ end
28
+ end.to_h
29
+ end
30
+
31
+ def named_arguments_with_allowed_fields(arguments, name=nil)
32
+ arguments.map do |key, value|
33
+ fields_hash = self.class::SUPPORTED_NAMED_ARGUMENT_FIELDS[name] || self.class::SUPPORTED_NAMED_ARGUMENT_FIELDS[key] || self.class::SUPPORTED_NAMED_ARGUMENT_FIELDS[key&.underscore] || []
34
+
35
+ case value
36
+ when Hash
37
+ [key, named_arguments_with_allowed_fields(value, key.underscore)]
38
+ when Array
39
+ [key, value.map {_1.is_a?(Hash) ? named_arguments_with_allowed_fields(_1, key.underscore) : _1}]
40
+ else
41
+ (fields_hash.empty? || fields_hash.include?(key)) ? [key, value] : [nil, nil]
42
+ end
43
+ end.to_h.compact_blank
44
+ end
45
+
46
+ def format_graphql_item(item)
47
+ case item
48
+ when Hash
49
+ "{ #{item.map { |k, v| "#{k}: #{v.is_a?(String) ? enum_friendly(v) : format_graphql_item(v)}" }.join(', ')} }"
50
+ when Array
51
+ "[ #{item.map { |i| format_graphql_item(i) }.join(', ')} ]"
52
+ else
53
+ enum_friendly(item)
54
+ end
55
+ end
56
+
57
+ def enum_friendly(value)
58
+ case value
59
+ when String
60
+ value.match?(/\A[A-Z_]+\z/) ? value : "\"#{value}\""
61
+ else
62
+ value
63
+ end
64
+ end
65
+
66
+ def format_graphql_args(args)
67
+ args.map do |key, value|
68
+ case value
69
+ when Hash
70
+ "#{key}: { #{format_graphql_args value} }"
71
+ when Array
72
+ if (value.first.is_a? Hash)
73
+ "#{key}: [ #{value.map { |v| "{ #{format_graphql_args v} }" }.join(', ')} ]"
74
+ else
75
+ "#{key}: [ #{value.map { |v| enum_friendly(v) }.join(', ')} ]"
76
+ end
77
+ when String
78
+ "#{key}: #{enum_friendly(value)}"
79
+ else
80
+ "#{key}: #{value}"
81
+ end
82
+ end.join(', ')
83
+ end
84
+
85
+ end
86
+ #
87
+ # creates a graphql mutation input.
88
+ # if just input as arg, use:
89
+ # input.new(
90
+ # [{...}, {...}]
91
+ # ).to_graphql_args
92
+ #
93
+ # Otherwise, you can pass named arguments in for each graphql argument:
94
+ # input.new(
95
+ # product_id: "gid/123",
96
+ # variants: [{...}, {...}]
97
+ # ).to_graphql_args
98
+ #
@@ -0,0 +1,78 @@
1
+
2
+ module EPlat::Shopify::GraphQL::V202407::Mutation::Product::Variant
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+
7
+ def self.product_variant_create
8
+ ->(args, additional_graphql: nil) do
9
+ <<~GRAPHQL
10
+ mutation {
11
+ #{additional_graphql}
12
+ productVariantCreate(#{args}) {
13
+ productVariant {
14
+ #{EPlat::Shopify::Product::Variant.graphql_fields}
15
+ }
16
+ }
17
+ }
18
+ GRAPHQL
19
+ end
20
+ end
21
+
22
+ def self.product_variant_update
23
+ ->(args, additional_graphql: nil) do
24
+ <<~GRAPHQL
25
+ mutation {
26
+ #{additional_graphql}
27
+ productVariantUpdate(#{args}) {
28
+ productVariant {
29
+ #{EPlat::Shopify::Product::Variant.graphql_fields}
30
+ }
31
+ }
32
+ }
33
+ GRAPHQL
34
+ end
35
+ end
36
+
37
+ def self.product_variant_delete
38
+ ->(args, additional_graphql: nil) do
39
+ <<~GRAPHQL
40
+ mutation {
41
+ #{additional_graphql}
42
+ productVariantDelete(#{args}) {
43
+ deletedProductVariantId
44
+ userErrors {
45
+ field
46
+ message
47
+ }
48
+ }
49
+ }
50
+ GRAPHQL
51
+ end
52
+ end
53
+
54
+ def self.product_variants_bulk_update
55
+ ->(args, additional_graphql: nil) do
56
+ <<~GRAPHQL
57
+ mutation {
58
+ #{product_variants_bulk_update_fragment.call(args, additional_graphql: additional_graphql)}
59
+ }
60
+ GRAPHQL
61
+ end
62
+ end
63
+
64
+ def self.product_variants_bulk_update_fragment
65
+ ->(args, additional_graphql: nil) do
66
+ <<~GRAPHQL
67
+ #{additional_graphql}
68
+ productVariantsBulkUpdate(#{args}) {
69
+ productVariants {
70
+ #{EPlat::Shopify::Product::Variant.graphql_fields}
71
+ }
72
+ }
73
+ GRAPHQL
74
+ end
75
+ end
76
+
77
+ end
78
+ end
@@ -0,0 +1,55 @@
1
+
2
+ module EPlat::Shopify::GraphQL::V202407::Mutation::Product
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+
7
+ def self.product_create
8
+ ->(args, additional_graphql: nil) do
9
+ <<~GRAPHQL
10
+ mutation {
11
+ #{additional_graphql}
12
+ productCreate(#{args}) {
13
+ product {
14
+ #{EPlat::Shopify::Product.graphql_fields}
15
+ }
16
+ }
17
+ }
18
+ GRAPHQL
19
+ end
20
+ end
21
+
22
+ def self.product_update
23
+ ->(args, additional_graphql: nil) do
24
+ <<~GRAPHQL
25
+ mutation {
26
+ #{additional_graphql}
27
+ productUpdate(#{args}) {
28
+ product {
29
+ #{EPlat::Shopify::Product.graphql_fields}
30
+ }
31
+ }
32
+ }
33
+ GRAPHQL
34
+ end
35
+ end
36
+
37
+ def self.product_delete
38
+ ->(args, additional_graphql: nil) do
39
+ <<~GRAPHQL
40
+ mutation {
41
+ #{additional_graphql}
42
+ productDelete(#{args}) {
43
+ deletedProductId
44
+ userErrors {
45
+ field
46
+ message
47
+ }
48
+ }
49
+ }
50
+ GRAPHQL
51
+ end
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ class EPlat::Shopify::GraphQL::V202407::Mutation
2
+ include Product, Product::Variant
3
+ end
4
+
5
+
@@ -0,0 +1,44 @@
1
+
2
+ module EPlat::Shopify::GraphQL::V202407::Query::Product::Variant
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+
7
+ def self.variants
8
+ ->(args) do
9
+ formatted_args = args.present? ? "(#{args})" : ""
10
+
11
+ <<~GRAPHQL
12
+ query getProductVariants {
13
+ productVariants#{formatted_args} {
14
+ nodes {
15
+ #{EPlat::Shopify::Product::Variant.graphql_fields}
16
+ }
17
+ pageInfo {
18
+ endCursor
19
+ startCursor
20
+ hasNextPage
21
+ hasPreviousPage
22
+ }
23
+ }
24
+ }
25
+ GRAPHQL
26
+ end
27
+ end
28
+
29
+ def self.variant
30
+ ->(args) do
31
+ formatted_args = args.present? ? "(#{args})" : ""
32
+
33
+ <<~GRAPHQL
34
+ query getProductVariant {
35
+ productVariant#{formatted_args} {
36
+ #{EPlat::Shopify::Product::Variant.graphql_fields}
37
+ }
38
+ }
39
+ GRAPHQL
40
+ end
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,58 @@
1
+
2
+ module EPlat::Shopify::GraphQL::V202407::Query::Product
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+
7
+ def self.products
8
+ ->(args) do
9
+ formatted_args = args.present? ? "(#{args})" : ""
10
+
11
+ <<~GRAPHQL
12
+ query getProducts {
13
+ products#{formatted_args} {
14
+ nodes {
15
+ #{EPlat::Shopify::Product.graphql_fields}
16
+ }
17
+ pageInfo {
18
+ endCursor
19
+ startCursor
20
+ hasNextPage
21
+ hasPreviousPage
22
+ }
23
+ }
24
+ }
25
+ GRAPHQL
26
+ end
27
+ end
28
+
29
+ def self.product
30
+ ->(args) do
31
+ formatted_args = args.present? ? "(#{args})" : ""
32
+
33
+ <<~GRAPHQL
34
+ query getProduct {
35
+ product#{formatted_args} {
36
+ #{EPlat::Shopify::Product.graphql_fields}
37
+ }
38
+ }
39
+ GRAPHQL
40
+ end
41
+ end
42
+
43
+ def self.products_count
44
+ ->(args) do
45
+ formatted_args = args.present? ? "(#{args})" : ""
46
+
47
+ <<~GRAPHQL
48
+ query productsCount {
49
+ productsCount#{formatted_args} {
50
+ count
51
+ }
52
+ }
53
+ GRAPHQL
54
+ end
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,5 @@
1
+ class EPlat::Shopify::GraphQL::V202407::Query
2
+ include Product, Product::Variant
3
+ end
4
+
5
+
@@ -1,2 +1,14 @@
1
1
 
2
- class EPlat::Shopify::Product::Image < EPlat::Product::Image; end
2
+ class EPlat::Shopify::Product::Image < EPlat::Product::Image
3
+ def self.graphql_fields
4
+ @@graphql_fields ||=
5
+ <<~GRAPHQL.freeze
6
+ id
7
+ altText
8
+ width
9
+ height
10
+ url
11
+ GRAPHQL
12
+
13
+ end
14
+ end
@@ -1,2 +1,14 @@
1
1
 
2
- class EPlat::Shopify::Product::Option < EPlat::Product::Option; end
2
+ class EPlat::Shopify::Product::Option < EPlat::Product::Option
3
+
4
+ def self.graphql_fields
5
+ @@graphql_fields ||=
6
+ <<~GRAPHQL.freeze
7
+ id
8
+ name
9
+ position
10
+ values
11
+ GRAPHQL
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+
2
+ class EPlat::Shopify::Product::Variant::OptionValue < EPlat::Product::Variant::OptionValue
3
+ def self.graphql_fields
4
+ @@graphql_fields ||=
5
+ <<~GRAPHQL.freeze
6
+ name
7
+ value
8
+ optionValue {
9
+ id
10
+ name
11
+ }
12
+ GRAPHQL
13
+ end
14
+ end
@@ -1,2 +1,66 @@
1
1
 
2
- class EPlat::Shopify::Product::Variant < EPlat::Product::Variant; end
2
+ class EPlat::Shopify::Product::Variant < EPlat::Product::Variant
3
+ requests_via_graphql with: {
4
+ find_every: "EPlat::Shopify::GraphQL::{API_VERSION}::Query.variants",
5
+ find_single: "EPlat::Shopify::GraphQL::{API_VERSION}::Query.variant",
6
+ find_one: "EPlat::Shopify::GraphQL::{API_VERSION}::Query.variants",
7
+ create: "EPlat::Shopify::GraphQL::{API_VERSION}::Mutation.product_variant_create",
8
+ update: "EPlat::Shopify::GraphQL::{API_VERSION}::Mutation.product_variant_update",
9
+ delete: "EPlat::Shopify::GraphQL::{API_VERSION}::Mutation.product_variant_delete"
10
+ }, unless: -> { EPlat.config.shopify_api_version == "2024_01" }
11
+
12
+ def self.graphql_fields
13
+ @@graphql_fields ||=
14
+ <<~GRAPHQL.freeze
15
+ id
16
+ title
17
+ price
18
+ sku
19
+ position
20
+ inventoryPolicy
21
+ compareAtPrice
22
+ inventoryManagement
23
+ selectedOptions {
24
+ #{ OptionValue.graphql_fields }
25
+ }
26
+ createdAt
27
+ updatedAt
28
+ taxable
29
+ barcode
30
+ weight
31
+ image {
32
+ id
33
+ }
34
+ inventoryItem {
35
+ id
36
+ measurement {
37
+ weight{
38
+ unit
39
+ value
40
+ }
41
+ }
42
+ tracked
43
+ requiresShipping
44
+ }
45
+ inventoryQuantity
46
+ legacyResourceId
47
+ price
48
+ compareAtPrice
49
+ taxCode
50
+ GRAPHQL
51
+ end
52
+
53
+ def graphql_input
54
+ "EPlat::Shopify::GraphQL::#{EPlat.shopify_graphql_version}::Input::Product::Variant".constantize
55
+ end
56
+
57
+ def self.delete(id, options = {})
58
+ if client.api_version == "2024_01"
59
+ super(id, options)
60
+ else
61
+ resource = new(id: formatted_id(id))
62
+ resource.delete
63
+ end
64
+ end
65
+
66
+ end
@@ -1,4 +1,79 @@
1
1
 
2
2
  module EPlat::Shopify
3
- class Product < EPlat::Product; end
4
- end
3
+ class Product < EPlat::Product
4
+ requests_via_graphql with: {
5
+ find_every: "EPlat::Shopify::GraphQL::{API_VERSION}::Query.products",
6
+ find_single: "EPlat::Shopify::GraphQL::{API_VERSION}::Query.product",
7
+ find_one: "EPlat::Shopify::GraphQL::{API_VERSION}::Query.products",
8
+ create: "EPlat::Shopify::GraphQL::{API_VERSION}::Mutation.product_create",
9
+ update: "EPlat::Shopify::GraphQL::{API_VERSION}::Mutation.product_update",
10
+ delete: "EPlat::Shopify::GraphQL::{API_VERSION}::Mutation.product_delete"
11
+ }, unless: -> { EPlat.config.shopify_api_version == "2024_01" }
12
+
13
+ add_to_graphql_requests :update, -> (product) do
14
+ if product.as_json.dig("product", "variants")&.compact_blank.present?
15
+ product.variants_bulk_update_fragment
16
+ end
17
+ end
18
+
19
+ def self.graphql_fields
20
+ @@graphql_fields ||=
21
+ <<~GRAPHQL.freeze
22
+ id
23
+ legacyResourceId
24
+ descriptionHtml
25
+ createdAt
26
+ updatedAt
27
+ handle
28
+ productType
29
+ publishedAt
30
+ status
31
+ tags
32
+ templateSuffix
33
+ title
34
+ vendor
35
+ variants(first: 250) {
36
+ nodes {
37
+ #{Variant.graphql_fields}
38
+ }
39
+ }
40
+ options {
41
+ #{Option.graphql_fields}
42
+ }
43
+ images(first: 250) {
44
+ nodes {
45
+ #{Image.graphql_fields}
46
+ }
47
+ }
48
+ GRAPHQL
49
+ end
50
+
51
+ def self.delete(id, options = {})
52
+ if client.api_version == "2024_01"
53
+ super(id, options)
54
+ else
55
+ resource = new(id: id)
56
+ resource.delete
57
+ end
58
+ end
59
+
60
+ def graphql_input
61
+ "EPlat::Shopify::GraphQL::#{EPlat.shopify_graphql_version}::Input::Product".constantize
62
+ end
63
+
64
+ def product_variants_bulk_input
65
+ "EPlat::Shopify::GraphQL::#{EPlat.shopify_graphql_version}::Input::Product::VariantsBulk".constantize
66
+ end
67
+
68
+ def variants_bulk_update_fragment
69
+ graphql_proc = eval "EPlat::Shopify::GraphQL::#{ EPlat.shopify_graphql_version }::Mutation.product_variants_bulk_update_fragment"
70
+ native_attributes = mapping.via_native_attributes_where_possible(as_json)
71
+
72
+ graphql_proc.call product_variants_bulk_input.new(
73
+ product_id: native_attributes.dig("product", "id"),
74
+ variants: native_attributes.dig("product", "variants")
75
+ ).to_graphql_args
76
+ end
77
+
78
+ end
79
+ end
@@ -9,15 +9,10 @@ module EPlat
9
9
 
10
10
  schema do
11
11
  integer :id
12
- integer :product_id
13
- integer :position
14
- datetime :created_at
15
- datetime :updated_at
16
12
  string :alt
17
13
  integer :width
18
14
  integer :height
19
15
  string :src
20
- array :variant_ids
21
16
  string :admin_graphql_api_id
22
17
  end
23
18
 
@@ -25,6 +20,14 @@ module EPlat
25
20
  prefix_options[:product] ||= product.id
26
21
  super
27
22
  end
23
+
24
+ def variant_ids
25
+ product.variants.map(&:id)
26
+ end
27
+
28
+ def variant_ids=(ids)
29
+ raise EPlat::Error.new("EPlat doesn't support setting variant_ids on images")
30
+ end
28
31
 
29
32
  end
30
33
  end
@@ -6,10 +6,9 @@ module EPlat
6
6
 
7
7
  schema do
8
8
  integer :id
9
- integer :product_id
10
- string :name
9
+ string :name
11
10
  integer :position
12
- array :values
11
+ array :values
13
12
  end
14
13
 
15
14
  end
@@ -0,0 +1,17 @@
1
+ module EPlat
2
+ class Product::Variant
3
+ class OptionValue < Base
4
+ belongs_to :variant, class_name: "EPlat::Product::Variant"
5
+
6
+ class << self; end
7
+
8
+ schema do
9
+ integer :id
10
+ string :admin_graphql_api_id
11
+ string :name
12
+ string :value
13
+ end
14
+
15
+ end
16
+ end
17
+ end