Electronic transport in a zig-zag-edge graphene nanoribbon (GNR) and its modification by adsorbed transition metal porphyrins is studied by means of density functional theory calculations. The detachment reaction of the metal centre of the porphyrin is investigated both in the gas phase and for molecules adsorbed on the GNR. As most metal porphyrins are very stable against this reaction, it is found that these molecules bind only weakly to a perfect nanoribbon. However, interaction with a single-atom vacancy in the GNR results in chemical bonding by the transition metal centre being shared between nitrogen atoms in the porphyrin ring and the carbon atoms next to the vacancy in the GNR. For both the physisorbed and the chemisorbed geometry, the inclusion of van der Waals interaction results in a significant enlargement of the binding energy and reduction of the adsorption height. Electronic transport calculations using non-equilibrium Greens functions show that the conductivity of the GNR is altered by the chemisorbed porphyrin molecules. Since the metal centers of porphyrins carry an element-specific magnetic moment, not only the net conductance, but also the spin-dependent conductance of the GNR is affected. In particular, the adsorption of Ru-porphyrin on the single-atom vacancy results in a very large spin polarization of the current of 88% at small applied source-drain voltages. Based on our results, we suggest that a spin valve constructed from a GNR with ferromagnetic contacts could be used as a sensitive detector that could discriminate between various metal porphyrins.