A General Learning Framework for Open Ad Hoc Teamwork Using Graph-based Policy Learning