Katie Boulter came close to claiming the biggest scalp of her career as Iga Swiatek edged a three-set thriller to knock Great Britain out of the United Cup.