I've tried using the Geometry Generator with no success, and decided on a Virtual Layer"Virtual layer" and a SQL query
SELECT st_union(geometry) from layer_name
SELECT st_union(geometry)
FROM layer_name
You need to replace "layer_name""layer_name"
with your layer name.
The resulting virtual layer is based on the source layer and will not create any new data.
It's not the geometry generator style, but it should fix your problem.