Its been a while since i read Harry Potter but Cedric was literally THE GUY in my favourite book of the series (4th one). He was the most talented young wizard in the world. At worst he can be compared to Law, at best to Ace. He wasnt a nobody but a true prodigy.
And all those that died like Sirius, Snape, Moody, Barry Crouch Sr and Jr, Quirell, Bill and Charlie Weasley, Dumbledore, Lupin were of top level. They would be Yonko commanders or Shichibukai in One Piece. Perhaps one or two of them "only" were New World veteran level but at least they were of high pedigree. Dumbledore of course would be Whitebeard, WSM but old age got them.
Anyhow, One Piece really has failed in this department. Merry should have been the first victim in Syrup Village like in OPLA. I think the series would have been much better had Dorry died, a clear signal that says Welcome to The Grand Line. No more fun and games, even giants can be killed. Pell obviously should have died. At least one or two Strawhats as well during the journey.
Maybe I remember wrong, but I remember Cedric a Mary Sue that everybody was saying how cool he was, but the actual character was almost non existant, no arc, no nothing. He is just there to be cool and eventually die. And he has no arc just because somebody had to die, but it had to be an irrelevant character so that children would not be sad, and the same is for One Piece. He has even less depth than Pedro.
And I still believe your comparison to be wrong. All the characters that you are listing died in the last book or in the last pages of the penultimate book.
Most of them irrelevant (Moody, Crouch, Bill and Charlie) or semi irrelevant like Neji (Lupin).
And in the end, why are you comparing a battle shonen to Harry potter?
Nobody dies in shonen since the dawn of time, only bad guys.
Nobody dies in Naruto, nobody dies in Dragon Ball, nobody dies in HxH..
And when I say nobody I mean nobody relevant.
It's not like Kurapika or Leorio die in HxH, or any many character in Naruto.