add connect query middleware