Hi guys (first post here so go easy please :) )
Ok, I'm very new to graph DBs,
gremlin.net and Azure/Cosmos and pretty new to .NET too (it's not surprising I'm confused)
What I can do so far:
I spent a fair bit of time initially just on gremlin console. I have no trouble using that to work on the in-memory DB, and no trouble connecting to both the basic gremlin-server and even a Cosmos graph DB (just by editing remote.yaml).
In .Net, I can connect to said cosmos DB using the Azure API (DocumentClient, DocumentCollection etc.). However, I can only find out how to submit traversals as a string rather than using chaining. e.g.
var queryStr = "g.V().hasLabel('person').values('firstName')";
var query = client.CreateGremlinQuery<Microsoft.Azure.Graphs.Elements.Vertex>(graph, queryStr);
Even if I could build queries using chaining, the bigger picture here is that my boss wants code that is more portable and not so embedded with cosmos, so I'm looking at connecting
gremlin.net directly to cosmos, just as I can from the gremlin console.
This bit of code gives an error on the traversal:
var gremlinServer = new GremlinServer(hostname, port, enableSsl: true,
username: "/dbs/" + database + "/colls/" + collection,
password: authKey);
var driver = new DriverRemoteConnection(new GremlinClient(gremlinServer));
//var driver = new DriverRemoteConnection(new GremlinClient(new GremlinServer("localhost", 8182)));
var graph = new Gremlin.Net.Structure.Graph();
var g = graph.Traversal().WithRemote(driver);
g.V().Drop().Next(); // nullreferenceexception
However, if I swap over the 2 'driver' lines and connect locally instead, everything is fine. I know the connection to cosmos works as I can screw up the hostname to get a "no connection" error.
I have code that DOES work:
var gremlinServer = new GremlinServer(hostname, port, enableSsl: true,
username: "/dbs/" + database + "/colls/" + collection,
password: authKey); // same as above
// using new (At time of writing) gremlin.net 3.3.2, but also tried with 3.3.1 and 3.2.7 (the latter has slightly differernt params)
using (var gremlinClient = new GremlinClient(gremlinServer, new GraphSON2Reader(), new GraphSON2Writer(), GremlinClient.GraphSON2MimeType))
{
var task = gremlinClient.SubmitAsync<dynamic>("g.V().Drop()");
task.Wait();
Notice something different from the above code here? It doesn't wrap the client in a DriverRemoteConnection object. However, without this I can't (or don't know how to) create a graph traversal object, and so I am again stuck using string literals for traversals.
Sorry for the long post, and sorry if I've missed something obvious and/or have my terminology mixed up (I'm learning a lot of new stuff concurrently). I have lots of other questions, but this is enough for now!
In summary all I want is to use
gremlin.net to connect to cosmos WITHOUT using azure API methods and WITH a graph traversal object so I can create chained traversals.
TIA