Wales wing James has not figured since his two-minute appearance for the dragons against world champions South Africa in Pretoria back in June.
A groin problem has dogged his season so far but the three-times capped star showed no ill effects with a first-half strike at St Helen's.
Swansea led 23-18 at the break through tries from Rhys and Nathan Jones but Cardiff stole victory with a penalty try in the 89th minute after flanker Harbir Singh was red carded.
Llanelli return to the top of the table after a 25-18 triumph at Bridgend while Newport leapfrog Aberavon who slipped up at Pontypridd into second following their 28-16 bonus-point victory at Glamorgan Wanderers.
There were also home wins for Ebbw Vale over Neath and Cross Keys against Pontypool while there was a first success of the season for basement club Llandovery at Bedwas.