The Harry Potter books and movies are iconic works of fiction for the younger generations. While the various plots are set in a magical, adjacent version of our own world, the stories take place almost entirely within the encapsulated, magical world. Except that it's officially canon that wizards (and dragons) fought in WWI.
In Warner Brother's 2016 film Fantastic Beasts and Where to Find Them, the awkward Newt Scamander, as played by Eddie Redmayne, comes to America to continue his journey of writing a book on magical animals. He bumps into the non-magical Jacob Kowalski, as played by Dan Fogler, and the plot kicks off. Initially, the two characters don't understand or like each other until they have a heart-to-heart conversation.
They bond when Kowalski tells Scamander about his service in WWI. Scamander asks, "you fought in the war?" Kowalski says, "of course I fought in the war. Everyone fought in the war. You didn't fight in the war?" To which Scamander replies,
I worked mostly with dragons, Ukrainian Ironbellies, Eastern Front.
It's a deep scene that ends with the two forming a brotherhood rooted in shared service.
Eddie Redmayne also starred in a TV Serial set in WWI called Birdsong. (BBC One's Birdsong)
Yes. That means, in the Harry Potter universe, WWI occurred just as it did in the real world. There were gigantic battles involving wizards and dragons that took place alongside the normal WWI trench-warfare.
This is confirmed through J.K. Rowling's other works on Pottermore, which is a cannon supplementary site on which the author expands her universe. She describes that wizards were barred from helping the normal world, but did anyway. This was actually a huge turning point in the overall story because it's one of the reasons why wizards don't interact with non-wizards.
To top it all off, she also wrote about Henry Potter, Harry's great-grandfather and namesake. Henry Potter was one of the British Wizards who participated in the trench warfare of WWI. His friendship with the non-magical world also played a huge role in Harry's backstory because it's why his family was shunned by most of the magical community.