active_shopify_graphql 0.5.0 → 0.5.2
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 +4 -4
- data/lib/active_shopify_graphql/model/attributes.rb +9 -2
- data/lib/active_shopify_graphql/model/connections.rb +7 -1
- data/lib/active_shopify_graphql/model/finder_methods.rb +4 -2
- data/lib/active_shopify_graphql/query/relation.rb +15 -2
- data/lib/active_shopify_graphql/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e31c1e3cd47c1a256fa09dd9cc1457a227c8773f372d97156a0a3d7fb1ed1a78
|
|
4
|
+
data.tar.gz: 84ede826d98ae8dab30c59808bff5275702ff547225c12e053b4330e262c6675
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8294f6fb6de67eec0843aaf85a86692da10724ceb0bfe1aaff9a8bd4a53260ce3a917fc834822466e3e0df3b0d1e3bdc62f299e2b5c7277c08a97a357c7c5114
|
|
7
|
+
data.tar.gz: fa1ef4907d94c0415b1fc479aa85027a7dcc15a96123f625bb20e3eb331f9ce42a519ebdf84aeb4007911c81ec6719f3f32a9a8e6bf7e9e8f75f3816f89442e5
|
|
@@ -19,10 +19,17 @@ module ActiveShopifyGraphQL::Model::Attributes
|
|
|
19
19
|
|
|
20
20
|
if @current_loader_context
|
|
21
21
|
# Store in loader-specific context
|
|
22
|
+
@loader_contexts ||= {}
|
|
23
|
+
@loader_contexts[@current_loader_context] ||= {}
|
|
22
24
|
@loader_contexts[@current_loader_context][name] = config
|
|
23
25
|
else
|
|
24
|
-
# Store in base attributes
|
|
25
|
-
@base_attributes ||=
|
|
26
|
+
# Store in base attributes, inheriting from parent if needed
|
|
27
|
+
@base_attributes ||=
|
|
28
|
+
if superclass.instance_variable_defined?(:@base_attributes)
|
|
29
|
+
superclass.instance_variable_get(:@base_attributes).dup
|
|
30
|
+
else
|
|
31
|
+
{}
|
|
32
|
+
end
|
|
26
33
|
@base_attributes[name] = config
|
|
27
34
|
end
|
|
28
35
|
|
|
@@ -6,7 +6,13 @@ module ActiveShopifyGraphQL::Model::Connections
|
|
|
6
6
|
included do
|
|
7
7
|
class << self
|
|
8
8
|
def connections
|
|
9
|
-
|
|
9
|
+
# Inherit connections from parent class if it responds to connections
|
|
10
|
+
@connections ||=
|
|
11
|
+
if superclass.respond_to?(:connections)
|
|
12
|
+
superclass.connections.dup
|
|
13
|
+
else
|
|
14
|
+
{}
|
|
15
|
+
end
|
|
10
16
|
end
|
|
11
17
|
|
|
12
18
|
attr_writer :connections
|
|
@@ -11,11 +11,13 @@ module ActiveShopifyGraphQL::Model::FinderMethods
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
# Find a single record by ID
|
|
14
|
-
#
|
|
14
|
+
# For Customer Account API, if no ID is provided, fetches the current customer
|
|
15
|
+
# @param id [String, Integer, nil] The record ID (will be converted to GID automatically)
|
|
15
16
|
# @param loader [ActiveShopifyGraphQL::Loader] The loader to use for fetching data (deprecated, use Relation chain)
|
|
16
17
|
# @return [Object] The model instance
|
|
17
18
|
# @raise [ActiveShopifyGraphQL::ObjectNotFoundError] If the record is not found
|
|
18
|
-
|
|
19
|
+
# @raise [ArgumentError] If id is nil and not using Customer Account API loader
|
|
20
|
+
def find(id = nil)
|
|
19
21
|
all.find(id)
|
|
20
22
|
end
|
|
21
23
|
|
|
@@ -75,10 +75,23 @@ module ActiveShopifyGraphQL
|
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
# Find a single record by ID
|
|
78
|
-
#
|
|
78
|
+
# For Customer Account API, if no ID is provided, fetches the current customer
|
|
79
|
+
# @param id [String, Integer, nil] The record ID (will be converted to GID automatically)
|
|
79
80
|
# @return [Object] The model instance
|
|
80
81
|
# @raise [ObjectNotFoundError] If the record is not found
|
|
81
|
-
|
|
82
|
+
# @raise [ArgumentError] If id is nil and not using Customer Account API loader
|
|
83
|
+
def find(id = nil)
|
|
84
|
+
# Handle Customer Account API case where no ID means "current customer"
|
|
85
|
+
if id.nil?
|
|
86
|
+
raise ArgumentError, "find requires an ID argument unless using Customer Account API" unless loader.is_a?(ActiveShopifyGraphQL::Loaders::CustomerAccountApiLoader)
|
|
87
|
+
|
|
88
|
+
attributes = loader.load_attributes
|
|
89
|
+
raise ObjectNotFoundError, "Couldn't find current customer" if attributes.nil?
|
|
90
|
+
|
|
91
|
+
return ModelBuilder.build(@model_class, attributes)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Standard case: find by ID
|
|
82
95
|
gid = GidHelper.normalize_gid(id, @model_class.model_name.name.demodulize)
|
|
83
96
|
attributes = loader.load_attributes(gid)
|
|
84
97
|
|