Let X be a smooth projective surface and D a smooth rational ample divisor in X. We prove an all-genus generalization of the genus 0 WDVV equation for primary Gromov--Witten invariants of the local 3-fold \mathcal{O}_X(-D). The proof relies on a correspondence between all-genus Gromov--Witten invariants and refined Donaldson--Thomas invariants of acyclic quivers. In particular, the corresponding BPS invariants are expressed in terms of Betti numbers of moduli spaces of quiver representations.