The Book of Jonah was never expected to be taken as a factual account. Let me say something about how it came to be written, placing it in its historical context.
The seventy year of the Babylonian Captivity ended in 530 B.C. when the people returned to Jerusalem to rebuild their temple. With help from Persia they completed the second temple in 515 B.C.
All should have been fine from then on, but it wasn’t. By 450 B.C. the city of Jerusalem was in need of heavy repairs, and criminal activity was on the increase among the people. Persia, still feeling responsibility for the Jews, appointed Ezra, a Jewish priest, and Nehemiah, a court official, to see what could be done for the city. In 445 B.C. they recommended making the old Law of Moses the civil law for the city.
That brought the people around, but it went too far. It had the Jews avoiding all contact with non-Jews.
Jonah, in the Book of Jonah, makes fun of the Jewish extremes who would have nothing to do with foreigners. When told to go to Nineveh to save them from their sins, Jonah, who hates the people there tried to travel west away from God’s commands.
After the whale threw him up, Jonah very reluctantly went to save Nineveh from their sins; and when they heeded his warning, and were saved, he was angry because he wanted to see them destroyed.
The story of Jonah was a humorous fiction written against hating foreigners.