If the baking chocolate gets overcooked then it will turn grainy. This recipe uses both baking chocolate and cocoa powder to help prevent this from happening, but if you let the chocolate boil for a while then you could still end up with grainy sauce. Next time, turn the heat down to low as soon as the mixture starts to bubble.