Defendants can sometimes plead guilty or no contest while holding onto the right to appeal a ruling by the trial judge. Depending on the issue and the state, defendants who plead pursuant to plea deals may not have to explicitly reserve the right to appeal a conviction or a ruling that led to it. (But see Can you lose the right to appeal a ruling by taking a plea deal?)
In many circumstances, in order to appeal a particular ruling, the defendant has to reach an agreement with the prosecution that the judge must approve, and that allows for appeal.
To understand reservation of the right to appeal and related issues, see Conditional Pleas.