Are your contacts/photos preserved when switching to GrapheneOS?
Discussion
Nope, you need to do some backing up beforehand, or ideally a new phone and transfer stuff over after flashed
As mentioned, unlocking the bootloader wipes the device, however this is necessary to install an alternate OS.
Export contacts as .vcf via the contacts app and backup photos to an external drive. (Thumbdrive, SSD or Computer).