For example, you could say:
* What is your name? (Here, "what" is the subject of the sentence)
* What are you doing? (Here, "what" is the object of the sentence)
To understand if a phrase with "what" is grammatically correct, you need to look at the whole sentence.