I have a Knowledge Graph database and I need to query it using Gremlin to get all connected nodes(Incoming + Outgoing) for a given Node. Right now I am using an approach where I query it twice to get Incoming and Outgoing connections. For outgoing connections, I am using -
"g.V().has('primaryName', 'NAME_OF_NODE').inE().outV().values('primaryName')"
For Incoming connections, I am using -
"g.V().has('primaryName', 'NAME_OF_NODE').outE().inV().values('primaryName')"
As of now I am running these as separate queries, is there any way to combine these two queries in a single query to save execution time.