Entanglement has evolved from an enigmatic concept of quantum physics to a key ingredient of quantum technology. It explains correlations between measurement outcomes that contradict classical physics and has been widely explored with small sets of individual qubits. Multi-partite entangled states build up in gate-based quantum-computing protocols and-from a broader perspective-were proposed as the main resource for measurement-based quantum-information processing1,2. The latter requires the ex-ante generation of a multi-qubit entangled state described by a graph3-6. Small graph states such as Bell or linear cluster states have been produced with photons7-16, but the proposed quantum-computing and quantum-networking applications require fusion of such states into larger and more powerful states in a programmable fashion17-21. Here we achieve this goal by using an optical resonator22 containing two individually addressable atoms23,24. Ring25 and tree26 graph states with up to eight qubits, with the names reflecting the entanglement topology, are efficiently fused from the photonic states emitted by the individual atoms. The fusion process itself uses a cavity-assisted gate between the two atoms. Our technique is, in principle, scalable to even larger numbers of qubits and is the decisive step towards, for instance, a memory-less quantum repeater in a future quantum internet27-29.