The story of Jonah was inspired by God, but was it factual? No, it wasn't. The Second Vatican Council clearly teaches us that among the books of the Bible, in addition to accurate historical accounts, there are as many types of writings as you will fins on any home library shelf. Let's see where the Book of Jonah fit in.
In 440 B.C. Jerusalem's elders took a strong stand against Jews mixing with Gentiles. They were trying to protect their faithful from pagan ways, but they went a little too far. The Book of Jonah was a humorous account of a Jew just going too far in avoiding foreigners.
The fictional account of Jonah pictures a Jew who so much hated the Gentiles in Nineveh, that he resisted God's summoning him to go save the people of Nineveh from their sins, First, he went far enough west that he thought he was beyond God's authority. When that didn't work, he went to Nineveh, telling the people they would die for their sins. hoping that they would perish.
When the people of Nineveh reformed their lives, avoiding their destruction, Jonah went off and sulked over it. God appeared to him, saying that he had to care for the Nineveh's thousands, who were also his children.