Module: ActiveShopifyGraphQL::Testing::FinderMethodsHook

Defined in:
lib/active_shopify_graphql/testing/hook.rb

Overview

Prepended onto FinderMethods::ClassMethods to return fresh TestLoader instances (preventing memoization leaks between tests).

Instance Method Summary collapse

Instance Method Details

#default_loaderObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/active_shopify_graphql/testing/hook.rb', line 20

def default_loader
  return super unless ActiveShopifyGraphQL::Testing.enabled?

  # Return a fresh instance each time to prevent state leakage between tests.
  eagerly_loaded_connections = connections.select { |_name, config| config[:eager_load] }.keys
  ActiveShopifyGraphQL::Testing::TestLoader.new(
    self,
    included_connections: eagerly_loaded_connections
  )
end