File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ def clear_clients
39
39
@_client_cache = { }
40
40
end
41
41
42
- def initialize_clients
42
+ def initialize_clients ( raise_on_invalid_schema : true )
43
43
initialize_client_cache
44
44
45
45
Dir . glob ( schema_location . join ( "*.json" ) ) . each do |schema_file |
@@ -49,7 +49,11 @@ def initialize_clients
49
49
if matches
50
50
api_version = ShopifyAPI ::ApiVersion . new ( handle : matches [ 1 ] )
51
51
else
52
- raise InvalidSchema , "Invalid schema file name `#{ schema_file } `. Does not match format of: `<version>.json`."
52
+ if raise_on_invalid_schema
53
+ raise InvalidSchema , "Invalid schema file name `#{ schema_file } `. Does not match format of: `<version>.json`."
54
+ else
55
+ next
56
+ end
53
57
end
54
58
55
59
schema = ::GraphQL ::Client . load_schema ( schema_file . to_s )
Original file line number Diff line number Diff line change @@ -53,6 +53,17 @@ def teardown
53
53
end
54
54
end
55
55
56
+ test '#initialize_clients does not raise if raise_on_invalid_schema is set to false' do
57
+ version_fixtures ( 'unstable' ) do |dir |
58
+ ShopifyAPI ::GraphQL . schema_location = dir
59
+ FileUtils . touch ( ShopifyAPI ::GraphQL . schema_location . join ( 'nope.json' ) )
60
+
61
+ ShopifyAPI ::GraphQL . initialize_clients ( raise_on_invalid_schema : false )
62
+
63
+ assert ShopifyAPI ::GraphQL . client ( 'unstable' )
64
+ end
65
+ end
66
+
56
67
test '#client returns default schema if only one exists' do
57
68
version_fixtures ( 'unstable' ) do |dir |
58
69
ShopifyAPI ::Base . api_version = 'unstable'
You can’t perform that action at this time.
0 commit comments