make gql plugin usable in browser

I was trying to query some more complex stuff
and fixed a type in the gql plugin and also
made pouch.collate usable
in the browser (wrapped it in a function)
as well as in nodejs (check for module variable).