Graphene has extraordinary electronic and optical properties and holds great promise for applications in photonics and optoelectronics. Demonstrations including high-speed photodetectors, optical modulators, plasmonic devices, and ultrafast lasers have now been reported. More advanced device concepts would involve photonic elements such as cavities to control light–matter interaction in graphene. Here we report the first monolithic integration of a graphene transistor and a planar, optical microcavity. We find that the microcavity-induced optical confinement controls the efficiency and spectral selection of photocurrent generation in the integrated graphene device. A twenty-fold enhancement of photocurrent is demonstrated. The optical cavity also determines the spectral properties of the electrically excited thermal radiation of graphene. Most interestingly, we find that the cavity confinement modifies the electrical transport characteristics of the integrated graphene transistor. Our experimental approach opens up a route towards cavity-quantum electrodynamics on the nanometre scale with graphene as a current-carrying intra-cavity ... mehrmedium of atomic thickness.