Graff is Ender's friend, even though he may appear to be undermining him and going behind his back in many things. Graff keeps secrets from Ender, plots to challenge him, talks about him behind his back, and manipulates parts of his life. All of these sound more like traits of an enemy than traits of a friend, don't they? The key ingredient here is motive. An enemy, whenever he acts out, does it out of hatred and in an attempt to destroy their opposition. They manipulate and plot, all with the goal of hurting, offending, thwarting and undermining their enemy. A friend, however, does things to try to support, encourage, enhance, and boost their friends. Even if they do things that hurt sometimes (like be brutally honest, or push you too hard), it is all in the name of helping you to reach your potential, and helping you to improve yourself.
Which one of those motives can we assign to Graff? Does he do these things to Ender to destroy him? Does he do them to weaken and undermine him? Hardly. Instead, everything that Graff does--whether it seems friendly or not--is meant to strengthen Ender, boost him, help him to reach his potential, and to help him to be the happiest, in the end, that he can be. It is less helpful to look at the individual acts that Graff commits against Ender, and more important to look at the motive behind those acts. He is Ender's friend because everything he does, he does in the name of helping Ender. And, he does it at the risk of his own job--he repeatedly angers Major Anderson, breaking rules and code to help Ender. In the end, he even faces charges for his actions in helping Ender. Only a friend would risk that.
I hope that those thoughts helped; good luck!