optimized GraphDatabase#query
added promises and test case