Yes it does protect you from Shocking Grasp.
Shield from the SRD.
An Invisible barrier of magical force appears and protects you. Until the start of your next turn, you have a +5 bonus to AC, including against the triggering Attack, and you take no damage from Magic Missile.
It doesn't say that it can't block cantrip damage. In addition it increases the AC for the attack that you use the reaction on.
Shocking Grasp from the SRD.
Lightning springs from your hand to deliver a shock to a creature you try to touch. Make a melee spell Attack against the target. You have advantage on the Attack roll if the target is wearing armor made of metal. On a hit, the target takes 1d8 lightning damage, and it can't take reactions until the start of its next turn.
It doesn't say that it can't be blocked by the spell shield. It is a melee spell Attack which according to shield it just needs to be an 'Attack' for the reaction trigger. In addition you take damage and can't take reactions together so if you can prevent the first you have to prevent the other since it is a chain linked by 'and' in this situation.
After you cast shield the resolution happens because shield allows you to increase your AC before the Attack so you can potentially prevent the attack from hitting you.
From these two spells this is how the flow seems to turn out using page 194 of the PHB 'Making an Attack' step three.
You make the attack roll. On a hit, you roll damage, unless the particular attack has rules that specify otherwise. Some attacks cause special effects in addition to or instead of damage.
This wording the shield effect would take place on the comma in this interpretation of "On a hit, you roll damage..." So it breaks the flow into these actions steps:
- Determine hit is successful. Player doesn't know total so they can't metagame in this situation.
- Shield reactions are triggered allowing you to increase your AC, including the triggering attack.
- Re-determine if the hit is successful. There is still a chance that it is if the player can't metagame this knowledge. e.g. the player's AC is 15, but the attacker rolled a 20 total for hitting the player.
Since the reaction prevention only comes with the damage that is dealt and shield could prevent the damage from being dealt in the first place it seems to reason that shield can be used since you would be able to prevent the damage.
Now if the attack roll and damage roll happened at the same time then no you wouldn't be able to prevent this, but there is an ordered set of steps in the 'Make an Attack' step 3 outline where hit must come before damage.