The principal testing ground for general relativity is the observable Universe. Gravitational lensing is the leading observational technique that gives insight into the distribution of baryonic matter in the stellar, galactic and cosmological scale, as well as the distribution of dark matter and dark energy, due to their gravitational interaction. Interpretation of ever more precise observational data requires increasingly subtle analytical techniques. In this paper, I discuss a formalism that can handle a nonlinear superposition of gravitational and refractive lensing by a grouping of baryonic matter, dark matter and dark energy for a given distribution of those entities (i.e. for a given spacetime metric) and their refractive properties. The role of refraction in gravitational lensing is exemplified in the case of a microlensing event and a signature of such an effect is discussed.