NodeMCU control 12v solenoid
No, you shouldn't connect a 9V source to an output pin of the MCU when the MCU is running at 3V. You will forward bias the input protection diode on the MCU. It might work, for a while, but it's really not a good idea.

Also, changing the gate voltage from 4.35V to 6V will not give good on/off control of the solenoid.