This can happen if the chocolate isn't completely melted or if the eggs are cold when added to the warm or room-temperature chocolate. Prevent graininess by making sure all the ingredients are at room temperature.