  Context. Stellar magnetic fields are one of the candidates often invoked to
explain the missing transport of angular momentum observed in the models of
stellar interiors. However, the properties of an internal magnetic field and
the consequences of its presence on stellar evolution are largely unknown.
  Aims. We study the effect of an axisymmetric internal magnetic field on the
frequency of gravity modes in rapidly rotating stars to check whether gravity
modes can be used to detect and probe such a field.
  Methods. Rotation is taken into account using the traditional approximation
of rotation and the effect of the magnetic field is computed using a
perturbative approach. As a proof of concept, we compute frequency shifts due
to a mixed (i.e. with both poloidal and toroidal components) fossil magnetic
field for a representative model of a known magnetic, rapidly rotating, slowly
pulsating B-type star, namely HD 43317.
  Results. We find that frequency shifts induced by the magnetic field scale
with the square of its amplitude. A magnetic field with a near-core strength of
order 150 kG (which is consistent with the observed surface field strength of
order 1 kG) leads to signatures that are detectable in period spacings for
high-radial-order gravity modes.
  Conclusions. The predicted frequency shifts can be used to constrain internal
magnetic fields and offers the potential for a significant step forward in our
interpretation of the observed structure of gravity-mode period spacing
patterns in rapidly rotating stars.
