In a query, should the synopsis tell the whole story in a short form or should it leave mystery to the story like on the back of the book?
Queries and synopses are different things. A query should never include a synopsis.
A query is a one-page letter that explains what you’ve written, who you are, and why the agent or publisher should consider your work. A query letter will contain a pitch, which is an explanation of your story in 3-8 sentences. It’s like the text you see on the back of a DVD box. It’s designed to pique your interest. A pitch, like the back of a book or DVD, will not spill the beans regarding the ending.
A synopsis is a front-to-back telling of what happens in your story. It’s like sitting down with a 12-year-old and explaining your entire story in about five minutes. You explain who the characters are, what the conflict is, the three acts and, finally, what happens at the end (e.g., the villain dies). So, in a synopsis, you do indeed give away the ending. You would not do so in a pitch, and a pitch is what appears in a query. A publisher will probably ask for a synopsis IF your query has grabbed their attention.
Remember: First the query then and only then, IF REQUESTED, the synopsis.