Update graph.py

add check for foreign key = none... o/w for optional link fields, I was getting an error