Chocolate can seize if cooked too long or on too high of a temperature, which can cause a grainy texture. Since we're using cocoa powder instead of a chocolate bar or chocolate chips, the mixture should cook just fine as long as you cook over low heat. Powdered sugar that has not been sifted can also cause a grainy (or lumpy) consistency, so make sure you sift it first prior to whisking it in.