3

How can I connect to DocumentDB Emulator using the Graph API?

As the documentation only specifies the connection settings for the DocumentDB and MongoDB. What are the connection settings for connecting emulator using Graph API?

1 Answer 1

3

The Graph API uses the same connection as DocumentDB. Gremlin queries are issued directly against the DocumentClient object which should have been initialized with the regular DocDb credentials using the CreateGremlinQuery extension method.

Assuming you're using the .NET clients, both the graph and document operations require that you pass a reference to the collection you want to perform the operation against once your client is connected. For gremlin: var query = _client.CreateGremlinQuery<dynamic>(_collection, gremlin); where _collection is an instance of DocumentCollection.

Sign up to request clarification or add additional context in comments.

4 Comments

Suppose by emulator, we create a database that contain two collections: one containing the documents (DocumentDB data) and other one containing vertices and edges (Graph data). So if Graph API uses the same connection as DocumentDB, How these two collections can be differentiated?
I've updated the answer to show how to target a specific collection
Hi Jesse. I am also struggling to get this working and cannot follow your advice. My code works against Azure using the Gremlin.Net driver (which the Azure docs recommend) but I cannot make it work with the emulator. I get the error "unable to connect to the remote server" (which is the same error as when pointing Graph API code to a non-GraphAPI instance of CosmosDB on Azure). Are you using a different driver?
I'll ask a new question, specifying the Gremlin.Net driver.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.