Ok, this is the harder post to write. I have been mentally writing and rewriting it in my head for the past week, as I've read what other agents have said about the subject. I find that I differ substantially from them on my opinion of ghostwritten queries.
Like Jennifer Jackson said on her blog, I can indeed recognize the queries that have been done by "services". They have a very distinctive look to them, and I don't recommend going that route.
On the other hand, I appreciate a query that shows off the book to me... so if that means your friend or your mentor helps you write it, go for it. I'd rather be able to get a sense of what a book is about, if it's told in a skillful manner, than pass on something that's good... let me try to explain.
I have had clients who can't write a query letter and a synopsis to save their lives, but who write DAMN GOOD novels.
I have read query letters and synopses that are incredibly well done, and the novel itself is terrible.
When I read your query letter (or rather when Jodi reads it, but she's reading for me), I want to know what your book is about. I don't want to know the emotional ramifications of one character thinking about their inner navel, which is what a lot of mediocre query letters look like. I want conflict, hook, interesting situation, etc. If you can't convey that yourself, but someone else who has read your work can... let them help you. You would be doing yourself a disservice not to take advantage of the best help you can get in marketing your work. I mean, why are you searching for an agent, if not to have them go on to market your book for you?
I have helped write query letters for friends, and they have then taken my help, and added their own personal touches to it. I like to think that may have helped them in some way or another. I don't consider it cheating, what I've done.
And I'd rather see a good query, even if it's been "ghostwritten" than a bad query, any day.
Plus, the reason we ask for the first five pages is to judge whether your writing is any good, even if your query is god-awful terrible.