lib/graphql/dataloader.rb in graphql-2.3.2 vs lib/graphql/dataloader.rb in graphql-2.3.5

- old
+ new

@@ -86,10 +86,15 @@ def set_fiber_variables(vars) vars.each { |k, v| Thread.current[k] = v } nil end + # This method is called when Dataloader is finished using a fiber. + # Use it to perform any cleanup, such as releasing database connections (if required manually) + def cleanup_fiber + end + # Get a Source instance from this dataloader, for calling `.load(...)` or `.request(...)` on. # # @param source_class [Class<GraphQL::Dataloader::Source] # @param batch_parameters [Array<Object>] # @return [GraphQL::Dataloader::Source] An instance of {source_class}, initialized with `self, *batch_parameters`, @@ -229,12 +234,10 @@ def spawn_fiber fiber_vars = get_fiber_variables Fiber.new(blocking: !@nonblocking) { set_fiber_variables(fiber_vars) yield - # With `.transfer`, you have to explicitly pass back to the parent -- - # if the fiber is allowed to terminate normally, control is passed to the main fiber instead. - true + cleanup_fiber } end private