What makes a gay character work is when being gay does not encompass nor describe who they are. Someone's sexual preference should not be their complete identity, but rather attribute towards it as a part of who they are.
What makes a gay character not work in fiction is when their sexual preference is all that they can offer. I don't want or need them to be driven by stereotypes, people have lives, hobbies, interests, and goals outside of their dating life.
Writing a gay character is the same as writing any character. Write someone's interests, habits, give them a role to play, and make their gender/interest be something on the side, like a complimentary attribute. Unless their role is to challenge the notion of their preference, like a gay character who has to hide their sexuality from others in fear of repercussions, stuff like that can be the exception. But even then, they should offer more as a character than being gay. Just my two cents