Graph Class

The .NET client for a Curiosity Workspace. A Graph opens an authenticated connection, queues node and edge writes locally, and flushes them to the server on commit. Obtain an instance with one of the Connect factory methods and wrap it in using so pending work flushes and the connection closes cleanly.

class

Graph

public partial class Graph

Represents a connection to a remote graph database.

Namespace
Curiosity.Library

Methods

NameDescription
ConnectConnects to the graph database using the specified endpoint, token, and connector name.
WithLoggingFactorySets the logging factory for the graph instance.
WithTimeoutSets the timeout for the graph instance.
WithDryRunSets the dry run mode for the graph instance.
InitializeAccessControlAsyncInitializes access control asynchronously.
CacheAccessControlAsyncCaches access control asynchronously.
ListenToWebSocketMessagesListens to WebSocket messages.
SetAutoCommitCostSets the auto-commit cost for the graph instance.
CommitPendingAsyncCommits any pending operations asynchronously.
CloseCloses the graph instance.
DisposeDisposes the graph instance.
PauseIndexingPauses indexing asynchronously. Useful for large data ingestions.
ResumeIndexingResumes indexing asynchronously.
CreateEdgeSchemaAsyncCreates one or more edges types asynchronously.
CreateNodeSchemaAsync<T>Creates a node schema asynchronously based on a class definition.
GetNodeSchemaAsyncCreates a node schema asynchronously.
AddOrUpdateAdds or updates a node.
TryAddTries to add a node if it doesn't exist yet.
UpdateUpdates a node.
DeleteDeletes a node.
ToNode<T>Resolves a strongly-typed node instance to its Node key representation using the registered schema mapping.
AddOrUpdateWithOwnershipAdds or updates a node, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.
TryAddWithOwnershipAttempts to add a node if it doesn't exist yet, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.
LinkCreates a relationship (edge) between two nodes in the graph using the specified edge type.
UnlinkRemoves an edge of the specified type from one node to another in the graph.
UnlinkExceptRemoves all edges of the specified type originating from the source node (`from`) except those connecting to the `except` node.
AddAliasAdds an alias to a node in the graph database for the specified language.
RemoveAliasRemoves a single alias from a node in the graph database for the specified language.
ClearAliasesClears all aliases associated with the specified node in the graph.
FetchFolderContentAsyncFetches the content of a folder from the graph database based on the provided folder name, source name, and URI.
CreateUserAsyncAsynchronously creates a new user node in the graph database with the specified details.
CreateTeamAsyncCreates a new team in the graph database with the specified name and optional description.
CreateFolderAsyncCreates a folder node in the graph database with specified properties.
CreateContactCreates a new contact node with the specified email, first name, and last name.
CreateOrganizationCreates a new organization node in the graph database using the given domain as a unique identifier.
CreateWebPageCreates a web page node in the graph with the provided attributes.
CheckPermissionsChangedChecks whether the permissions of the specified file have been changed.
MapPermissionsAsyncMaps file access permissions in the graph database for the specified file path and file node.
UploadFileAndPermissionsAsyncUploads a file to the graph database and sets up permissions by mapping it to a graph node.
UploadFileAsyncUploads a file to the graph database and associates it with the specified source. Retries the operation until successful or the defined timeout elapses.
UploadFileWithIdentifierAsyncUploads a file to the graph database with a unique identifier, associating metadata such as filename and source.
UploadFileToFolderAsyncUploads a file to a specified folder in the graph database.
GetFileHashCompute a SHA256 hash for a given input stream file. The stream will be rewinded before and after computing the hash.
TryGetFileNodeAsyncTry getting the file node after checking if it exists in the graph, and optionally checking if the SHA256 hash is the same
DeleteFileAsyncDeletes a file from the specified source in the graph database.
DeleteFolderAsyncDeletes a folder from the graph database using the specified path and source name.
MarkFileAsPrivateMarks the specified file node as private by removing the public access edge.
MarkFolderAsPrivateMarks a folder node as private by removing its association with the public access group.
AddUserToTeamAdds a user node to a team node by creating a unique membership relationship between them.
AddAdminToTeamAdds a user as an admin to a specified team, creating appropriate edges in the graph database.
RemoveAdminFromTeamRemoves a user's admin rights on a team by removing the admin edges, while leaving the user's membership intact.
RemoveUserFromTeamRemoves a user from a team by removing all relevant edges between the user node and team node.
RestrictAccessToTeamRestricts access to a specific node by associating it with a team access group node.
RemoveAccessFromTeamRemoves a team access group as an owner of the specified node, revoking the access previously granted by RestrictAccessToTeam.
RestrictAccessToUserRestricts access to the specified node by associating it with a user node as its owner. Creates a bidirectional ownership relationship between the node and the user node.
RemoveAccessFromUserRemoves a user as an owner of the specified node, revoking the access previously granted by RestrictAccessToUser.
ClearPermissionsClears the permissions of the specified node, with an optional exception for specific owner nodes.
LogAsyncLogs a message asynchronously to the graph's logging system.
LogManyAsyncLogs a message asynchronously to the graph's logging system.
MapAsyncRetrieves a mapping of nodes to a specified field value for a given node type in the graph database, paged asynchronously.
UploadNewApplicationInterfaceAsyncUploads a new application interface to the system from the specified folder contents.
QueryAsyncExecutes a query against the graph database asynchronously.
ClearEmbeddingsIndexAsyncClears the embeddings index for the specified index UID in the graph database.
AddEmbeddingsToIndexAsyncAdds a collection of node embeddings to the specified index in batches.
ExportWorkspaceDefinitionAsyncExports workspace configuration
ImportWorkspaceDefinitionsAsyncImports workspace configuration
Method
Graph.Connect
Overload
Connect(string, string, string, HttpClientHandler)Connects to the graph database using the specified endpoint, token, and connector name.
Connect(string, X509Certificate, string, HttpClientHandler)Connects to the graph database using the specified endpoint, token, and connector name.
Connect(string, string, string, HttpClientHandler)
public static Graph Connect(string endpoint, string token, string connectorName, HttpClientHandler clientHandler = null)

Connects to the graph database using the specified endpoint, token, and connector name.

Parameters

endpoint string
The endpoint URL of the graph database.
token string
The authentication token.
connectorName string
The name of the connector.
clientHandler HttpClientHandler
Optional HTTP client handler.

Returns

A new instance of the Graph class.

Examples

 var graph = Graph.Connect("https://example.com", "my-token", "my-connector");
 
Connect(string, X509Certificate, string, HttpClientHandler)
public static Graph Connect(string endpoint, X509Certificate clientCertificate, string connectorName, HttpClientHandler clientHandler = null)

Connects to the graph database using the specified endpoint, token, and connector name.

Parameters

endpoint string
The endpoint URL of the graph database.
clientCertificate X509Certificate
connectorName string
The name of the connector.
clientHandler HttpClientHandler
Optional HTTP client handler.

Returns

A new instance of the Graph class.

Examples

 var graph = Graph.Connect("https://example.com", "my-token", "my-connector");
 
Method
Graph.WithLoggingFactory
public Graph WithLoggingFactory(ILoggerFactory loggerFactory)

Sets the logging factory for the graph instance.

Parameters

loggerFactory
The logger factory.

Returns

The current Graph instance.

Examples

 var graph = Graph.Connect("https://example.com", "my-token", "my-connector")
                 .WithLoggingFactory(loggerFactory);
 
Method
Graph.WithTimeout
public Graph WithTimeout(TimeSpan timeout)

Sets the timeout for the graph instance.

Parameters

timeout
The timeout duration.

Returns

The current Graph instance.

Examples

 var graph = Graph.Connect("https://example.com", "my-token", "my-connector")
                 .WithTimeout(TimeSpan.FromSeconds(30));
 
Method
Graph.WithDryRun
public Graph WithDryRun(bool dryRun = true)

Sets the dry run mode for the graph instance.

Parameters

dryRun
Whether to enable dry run mode.

Returns

The current Graph instance.

Examples

 var graph = Graph.Connect("https://example.com", "my-token", "my-connector")
                 .WithDryRun(true);
 
Method
Graph.InitializeAccessControlAsync
public async Task InitializeAccessControlAsync(string cachePath)

Initializes access control asynchronously.

Parameters

cachePath
The path to the cache file.

Returns

A task representing the asynchronous operation.

Examples

 await graph.InitializeAccessControlAsync("path/to/cache");
 
Method
Graph.CacheAccessControlAsync
public async Task CacheAccessControlAsync()

Caches access control asynchronously.

Returns

A task representing the asynchronous operation.

Examples

 await graph.CacheAccessControlAsync();
 
Method
Graph.ListenToWebSocketMessages
public void ListenToWebSocketMessages(Func<string, Task<string>> handleMessage, Action<ClientWebSocket> configureClient = null, CancellationToken cancellationToken = default)

Listens to WebSocket messages.

Parameters

handleMessage
The function to handle incoming messages.
cancellationToken
Optional cancellation token.

Examples

 graph.ListenToWebSocketMessages(async message => {
     // Handle the message
     return "response";
 });
 
Method
Graph.SetAutoCommitCost
public Graph SetAutoCommitCost(int everyNodes, int everyEdges = 0)

Sets the auto-commit cost for the graph instance.

Parameters

everyNodes
The number of nodes after which to auto-commit.
everyEdges
The number of edges after which to auto-commit.

Returns

The current Graph instance.

Examples

 var graph = Graph.Connect("https://example.com", "my-token", "my-connector")
                 .SetAutoCommitCost(100, 50);
 
Method
Graph.CommitPendingAsync
public async Task CommitPendingAsync()

Commits any pending operations asynchronously.

Returns

A task representing the asynchronous operation.

Examples

 await graph.CommitPendingAsync();
 
Method
Graph.Close
public void Close()

Closes the graph instance.

Examples

 graph.Close();
 
Method
Graph.Dispose
public void Dispose()

Disposes the graph instance.

Examples

 graph.Dispose();
 
Method
Graph.PauseIndexing
public async Task PauseIndexing(string pauseName)

Pauses indexing asynchronously. Useful for large data ingestions.

Parameters

pauseName
The name of the pause.

Returns

A task representing the asynchronous operation.

Examples

 await graph.PauseIndexing("pause1");
 
Method
Graph.ResumeIndexing
public async Task ResumeIndexing(string pauseName)

Resumes indexing asynchronously.

Parameters

pauseName
The name of the pause.

Returns

A task representing the asynchronous operation.

Examples

 await graph.ResumeIndexing("pause1");
 
Method
Graph.CreateEdgeSchemaAsync
Overload
CreateEdgeSchemaAsync(string[])Creates one or more edges types asynchronously.
CreateEdgeSchemaAsync(Type)Asynchronously creates an edge schema based on the provided static class containing edge type definitions.
CreateEdgeSchemaAsync(string[])
public async Task CreateEdgeSchemaAsync(params string[] edges)

Creates one or more edges types asynchronously.

Parameters

edges string[]
The names of the edges to create.

Returns

A task representing the asynchronous operation.

Examples

 await graph.CreateEdgeSchemaAsync("HasAuthor", "AuthorOf");
 
CreateEdgeSchemaAsync(Type)
public async Task CreateEdgeSchemaAsync(Type staticEdgesClass)

Asynchronously creates an edge schema based on the provided static class containing edge type definitions.

Parameters

staticEdgesClass Type
The static class containing public constant string fields representing edge types.

Returns

A task that represents the asynchronous operation.

Exceptions

ArgumentNullException
Thrown when staticEdgesClass is null.
ArgumentException
Thrown when staticEdgesClass is not a static class.

Remarks

This method extracts all public constant string fields from the specified static class and uses them as edge type definitions. If no valid edge types are found, no schema is created.

Examples

 public static class Edges
 {
     public const string HasPart = nameof(HasPart);
     public const string PartOf = nameof(PartOf);
 }
 
 //Call with:
 await graph.CreateEdgeSchemaAsync(typeof(Edges));
 
Method
Graph.CreateNodeSchemaAsync<T>
public Task CreateNodeSchemaAsync<T>(bool overwrite = false) where T : class

Creates a node schema asynchronously based on a class definition.

Type Parameters

T
The type of the node.

Parameters

overwrite
Whether to overwrite the existing schema.

Returns

A task representing the asynchronous operation.

Examples

 [Node]
 public class Author
 {
     [Key] public string Name { get; set; }
 }
 
 await graph.CreateNodeSchemaAsync
 
Method
Graph.GetNodeSchemaAsync
public async Task<NodeSchema> GetNodeSchemaAsync(string nodeType)

Creates a node schema asynchronously.

Parameters

schema
The schema to create.
overwrite
Whether to overwrite the existing schema.

Returns

A task representing the asynchronous operation.

Examples

 var schema = new Schema { /* schema definition */ };
 await graph.CreateNodeSchemaAsync(schema, overwrite: true);
 
Method
Graph.AddOrUpdate
Overload
AddOrUpdate<T>(T)Adds or updates a node.
AddOrUpdate<T>(IEnumerable<T>)Adds or updates a sequence of nodes.
AddOrUpdate(Node, object)Adds or updates a node with the specified content.
AddOrUpdate(Node)Adds or updates a node.
AddOrUpdate(Node, Action<NodeOperation>)Adds a new node or updates an existing node in the graph using a specified operation.
AddOrUpdate<T>(T)
public Node AddOrUpdate<T>(T node) where T : class

Adds or updates a node.

Parameters

node T
The node to add or update.

Type Parameters

T
The type of the node.

Returns

The added or updated node.

Examples

 var author = new Author { Name = "John Doe", Country = "USA" };
 var node = graph.AddOrUpdate(author);
 
AddOrUpdate<T>(IEnumerable<T>)
public Node[] AddOrUpdate<T>(IEnumerable<T> nodes) where T : class

Adds or updates a sequence of nodes.

Parameters

nodes IEnumerable<T>
The nodes to add or update.

Type Parameters

T
The type of the nodes.

Returns

The added or updated nodes, in the same order as nodes.

AddOrUpdate(Node, object)
public Node AddOrUpdate(Node node, object content)

Adds or updates a node with the specified content.

Parameters

node Node
The node to add or update.
content object
The content of the node.

Returns

The added or updated node.

Examples

 var node = Node.FromKey("Author", "john-doe");
 var content = new { Name = "John Doe", Country = "USA" };
 graph.AddOrUpdate(node, content);
 
AddOrUpdate(Node)
public Node AddOrUpdate(Node node)

Adds or updates a node.

Parameters

node Node
The node to add or update.

Returns

The added or updated node.

Examples

 var node = Node.FromKey("Author", "john-doe");
 graph.AddOrUpdate(node);
 
AddOrUpdate(Node, Action<NodeOperation>)
public Node AddOrUpdate(Node node, Action<NodeOperation> operation)

Adds a new node or updates an existing node in the graph using a specified operation.

Parameters

node Node
The node to be added or updated in the graph.
operation Action<NodeOperation>
The operation to modify the node during the add or update process.

Returns

The added or updated node.

Method
Graph.TryAdd
Overload
TryAdd<T>(T)Tries to add a node if it doesn't exist yet.
TryAdd<T>(IEnumerable<T>)Tries to add a sequence of nodes, skipping any that already exist.
TryAdd(Node)Attempts to add a new node to the graph. Does not override existing nodes with similar properties.
TryAdd(Node, Action<NodeOperation>)Attempts to add a new node to the graph with the specified operation. If the node already exists, no changes will be made.
TryAdd(Node, object)Attempts to add a node to the graph, associating it with the specified content, without overwriting an existing node if it already exists.
TryAdd<T>(T)
public Node TryAdd<T>(T node) where T : class

Tries to add a node if it doesn't exist yet.

Parameters

node T
The node to add.

Type Parameters

T
The type of the node.

Returns

The added node.

Examples

 var author = new Author { Name = "John Doe", Country = "USA" };
 var node = graph.TryAdd(author);
 
TryAdd<T>(IEnumerable<T>)
public Node[] TryAdd<T>(IEnumerable<T> nodes) where T : class

Tries to add a sequence of nodes, skipping any that already exist.

Parameters

nodes IEnumerable<T>
The nodes to add.

Type Parameters

T
The type of the nodes.

Returns

The added nodes, in the same order as nodes.

TryAdd(Node)
public Node TryAdd(Node node)

Attempts to add a new node to the graph. Does not override existing nodes with similar properties.

Parameters

node Node
The node to be added to the graph.

Returns

The newly added node, or the existing node if it already exists in the graph.

TryAdd(Node, Action<NodeOperation>)
public Node TryAdd(Node node, Action<NodeOperation> operation)

Attempts to add a new node to the graph with the specified operation. If the node already exists, no changes will be made.

Parameters

node Node
The node to add to the graph.
operation Action<NodeOperation>
The action to configure the node operation.

Returns

The node that was provided, regardless of whether it was added.

TryAdd(Node, object)
public Node TryAdd(Node node, object content)

Attempts to add a node to the graph, associating it with the specified content, without overwriting an existing node if it already exists.

Parameters

node Node
The node to be added to the graph.
content object
The content associated with the node.

Returns

The node that was attempted to be added.

Method
Graph.Update
Overload
Update<T>(T)Updates a node.
Update<T>(IEnumerable<T>)Updates a sequence of nodes.
Update(Node, Action<NodeOperation>)Updates the specified node in the graph using the defined operation.
Update(Node, object)Updates the content of an existing node in the graph.
Update<T>(T)
public Node Update<T>(T node) where T : class

Updates a node.

Parameters

node T
The node to update.

Type Parameters

T
The type of the node.

Returns

The updated node.

Examples

 var author = new Author { Name = "John Doe", Country = "USA" };
 var node = graph.Update(author);
 
Update<T>(IEnumerable<T>)
public Node[] Update<T>(IEnumerable<T> nodes) where T : class

Updates a sequence of nodes.

Parameters

nodes IEnumerable<T>
The nodes to update.

Type Parameters

T
The type of the nodes.

Returns

The updated nodes, in the same order as nodes.

Update(Node, Action<NodeOperation>)
public Node Update(Node node, Action<NodeOperation> operation)

Updates the specified node in the graph using the defined operation.

Parameters

node Node
The node to be updated in the graph.
operation Action<NodeOperation>
An action defining the update operation to be applied to the node.

Returns

The updated node instance.

Update(Node, object)
public Node Update(Node node, object content)

Updates the content of an existing node in the graph.

Parameters

node Node
The node to update.
content object
The new content to be set for the node.

Returns

The updated node instance.

Examples

 var bookNode = Node.FromKey("Book", "book-123");
 graph.Update(bookNode, new { Title = "New Title", Year = 2023 });
 
Method
Graph.Delete
Overload
Delete<T>(T)Deletes a node.
Delete<T>(IEnumerable<T>)Deletes a sequence of nodes.
Delete(Node)Deletes the specified node from the graph database.
Delete<T>(T)
public void Delete<T>(T node) where T : class

Deletes a node.

Parameters

node T
The node to delete.

Type Parameters

T
The type of the node.

Examples

 var author = new Author { Name = "John Doe", Country = "USA" };
 graph.Delete(author);
 
Delete<T>(IEnumerable<T>)
public void Delete<T>(IEnumerable<T> nodes) where T : class

Deletes a sequence of nodes.

Parameters

nodes IEnumerable<T>
The nodes to delete.

Type Parameters

T
The type of the nodes.
Delete(Node)
public void Delete(Node node)

Deletes the specified node from the graph database.

Parameters

node Node
The node to be deleted.

Examples

 var authorNode = Node.FromKey("Author", "John Doe");
 graph.Delete(authorNode);
 
Method
Graph.ToNode<T>
public Node ToNode<T>(T node) where T : class

Resolves a strongly-typed node instance to its Node key representation using the registered schema mapping.

Type Parameters

T
The type of the node. Must be decorated with NodeAttribute, unless it already is a Node.

Parameters

node
The strongly-typed node (or an existing Node, which is returned unchanged).

Returns

A Node identified by the mapped node type and key.

Examples

 var author = new Author { Name = "John Doe", Country = "USA" };
 var node   = graph.ToNode(author);
 graph.Link(node, otherNode, "Knows");
 
Method
Graph.AddOrUpdateWithOwnership
Overload
AddOrUpdateWithOwnership<T>(T, Node[])Adds or updates a node, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.
AddOrUpdateWithOwnership(Node, object, Node[])Adds or updates a node with the specified content, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.
AddOrUpdateWithOwnership(Node, Node[])Adds or updates a node, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.
AddOrUpdateWithOwnership(Node, Action<NodeOperation>, Node[])Adds or updates a node using the specified node operation, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.
AddOrUpdateWithOwnership<T>(T, Node[])
public Node AddOrUpdateWithOwnership<T>(T node, params Node[] owners) where T : class

Adds or updates a node, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.

Parameters

node T
The node to add or update.
owners Node[]
The nodes that should own the newly added or updated node.

Type Parameters

T
The type of the node.

Returns

The added or updated node.

Remarks

There is intentionally no UpdateWithOwnership variant: ownership is asserted by adding _OwnedBy edges, which is inherently an upsert, so use AddOrUpdateWithOwnership{T} to (re)assert ownership on an existing node. Use ClearPermissions first if you need to replace the existing owners rather than add to them.

AddOrUpdateWithOwnership(Node, object, Node[])
public Node AddOrUpdateWithOwnership(Node node, object content, params Node[] owners)

Adds or updates a node with the specified content, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.

Parameters

node Node
The node to add or update.
content object
The content of the node.
owners Node[]
The nodes that should own the node.

Returns

The added or updated node.

AddOrUpdateWithOwnership(Node, Node[])
public Node AddOrUpdateWithOwnership(Node node, params Node[] owners)

Adds or updates a node, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.

Parameters

node Node
The node to add or update.
owners Node[]
The nodes that should own the node.

Returns

The added or updated node.

AddOrUpdateWithOwnership(Node, Action<NodeOperation>, Node[])
public Node AddOrUpdateWithOwnership(Node node, Action<NodeOperation> operation, params Node[] owners)

Adds or updates a node using the specified node operation, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.

Parameters

node Node
The node to add or update.
operation Action<NodeOperation>
The operation that configures the node content.
owners Node[]
The nodes that should own the node.

Returns

The added or updated node.

Method
Graph.TryAddWithOwnership
Overload
TryAddWithOwnership<T>(T, Node[])Attempts to add a node if it doesn't exist yet, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.
TryAddWithOwnership(Node, Node[])Attempts to add a node, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.
TryAddWithOwnership(Node, Action<NodeOperation>, Node[])Attempts to add a node using the specified node operation, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.
TryAddWithOwnership(Node, object, Node[])Attempts to add a node with the specified content, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.
TryAddWithOwnership<T>(T, Node[])
public Node TryAddWithOwnership<T>(T node, params Node[] owners) where T : class

Attempts to add a node if it doesn't exist yet, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.

Parameters

node T
The node to add.
owners Node[]
The nodes that should own the newly added node.

Type Parameters

T
The type of the node.

Returns

The added node.

TryAddWithOwnership(Node, Node[])
public Node TryAddWithOwnership(Node node, params Node[] owners)

Attempts to add a node, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.

Parameters

node Node
The node to add.
owners Node[]
The nodes that should own the node.

Returns

The node passed in.

TryAddWithOwnership(Node, Action<NodeOperation>, Node[])
public Node TryAddWithOwnership(Node node, Action<NodeOperation> operation, params Node[] owners)

Attempts to add a node using the specified node operation, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.

Parameters

node Node
The node to add.
operation Action<NodeOperation>
The operation that configures the node content.
owners Node[]
The nodes that should own the node.

Returns

The node passed in.

TryAddWithOwnership(Node, object, Node[])
public Node TryAddWithOwnership(Node node, object content, params Node[] owners)

Attempts to add a node with the specified content, atomically linking it to the supplied owner nodes via _OwnedBy edges as part of the same locking operation. The reverse _Owns edges from each owner back to the node are queued and processed as regular batched edge operations.

Parameters

node Node
The node to add.
content object
The content of the node.
owners Node[]
The nodes that should own the node.

Returns

The node passed in.

Method
Graph.UnlinkExcept
Overload
UnlinkExcept(Node, Node, string)Removes all edges of the specified type originating from the source node (`from`) except those connecting to the `except` node.
UnlinkExcept(Node, Node, string, string)Removes all edges of the specified type from the 'from' node to other nodes, except for the edge to the 'except' node. Additionally, removes edges of the inverse specified type from the 'except' node to the 'from' node.
UnlinkExcept(Node, Node, string)
public void UnlinkExcept(Node from, Node except, string edgeType)

Removes all edges of the specified type originating from the source node (`from`) except those connecting to the `except` node.

Parameters

from Node
The source node from which edges will be removed.
except Node
The target node that should retain its connection with the source node.
edgeType string
The type of edge to remove, except for the connection to the `except` node.

Examples

 var author = Node.FromKey("Author", "JohnDoe");
 var book1 = Node.FromKey("Book", "BookA");
 var book2 = Node.FromKey("Book", "BookB");
 graph.UnlinkExcept(author, book1, "AuthorOf");
 
UnlinkExcept(Node, Node, string, string)
public void UnlinkExcept(Node from, Node except, string edgeTypeFromToExcept, string edgeTypeExceptToFrom)

Removes all edges of the specified type from the 'from' node to other nodes, except for the edge to the 'except' node. Additionally, removes edges of the inverse specified type from the 'except' node to the 'from' node.

Parameters

from Node
The source node from which outgoing edges will be removed.
except Node
The target node to which the edges will be retained.
edgeTypeFromToExcept string
The type of the outgoing edges from the 'from' node to the 'except' node.
edgeTypeExceptToFrom string
The type of the outgoing edges from the 'except' node to the 'from' node.

Examples

 var author = Node.FromKey("Author", "Author1");
 var book = Node.FromKey("Book", "Book1");
 graph.UnlinkExcept(author, book, "AuthorOf", "HasAuthor");
 
Method
Graph.AddAlias
Overload
AddAlias(Node, Language, string, bool)Adds an alias to a node in the graph database for the specified language.
AddAlias<T>(T, Language, string, bool)Adds an alias to a strongly-typed node in the graph database for the specified language.
AddAlias(Node, Language, string, bool)
public void AddAlias(Node from, Language language, string alias, bool ignoreCase)

Adds an alias to a node in the graph database for the specified language.

Parameters

from Node
The node to which the alias is being added.
language Language
The language associated with the alias.
alias string
The alias value to be added.
ignoreCase bool
If true, the alias comparison will ignore case.

Examples

 var authorNode = Node.FromKey("Author", "JohnDoe");
 graph.AddAlias(authorNode, Language.English, "JDoe", ignoreCase: true);
 
AddAlias<T>(T, Language, string, bool)
public void AddAlias<T>(T from, Language language, string alias, bool ignoreCase) where T : class

Adds an alias to a strongly-typed node in the graph database for the specified language.

Parameters

from T
The node to which the alias is being added.
language Language
The language associated with the alias.
alias string
The alias value to be added.
ignoreCase bool
If true, the alias comparison will ignore case.

Type Parameters

T
The type of the node. Must be decorated with NodeAttribute.
Method
Graph.RemoveAlias
Overload
RemoveAlias(Node, Language, string, bool)Removes a single alias from a node in the graph database for the specified language.
RemoveAlias<T>(T, Language, string, bool)Removes a single alias from a strongly-typed node in the graph database for the specified language.
RemoveAlias(Node, Language, string, bool)
public void RemoveAlias(Node from, Language language, string alias, bool ignoreCase)

Removes a single alias from a node in the graph database for the specified language.

Parameters

from Node
The node from which the alias is being removed.
language Language
The language associated with the alias.
alias string
The alias value to be removed.
ignoreCase bool
Must match the ignoreCase value the alias was added with, so the same alias node is resolved.

Examples

 var authorNode = Node.FromKey("Author", "JohnDoe");
 graph.RemoveAlias(authorNode, Language.English, "JDoe", ignoreCase: true);
 
RemoveAlias<T>(T, Language, string, bool)
public void RemoveAlias<T>(T from, Language language, string alias, bool ignoreCase) where T : class

Removes a single alias from a strongly-typed node in the graph database for the specified language.

Parameters

from T
The node from which the alias is being removed.
language Language
The language associated with the alias.
alias string
The alias value to be removed.
ignoreCase bool
Must match the ignoreCase value the alias was added with, so the same alias node is resolved.

Type Parameters

T
The type of the node. Must be decorated with NodeAttribute.
Method
Graph.ClearAliases
Overload
ClearAliases(Node)Clears all aliases associated with the specified node in the graph.
ClearAliases<T>(T)Clears all aliases associated with the specified strongly-typed node in the graph.
ClearAliases(Node)
public void ClearAliases(Node from)

Clears all aliases associated with the specified node in the graph.

Parameters

from Node
The node whose aliases need to be cleared.

Examples

 var author = Node.FromKey("Author", "JohnDoe");
 graph.ClearAliases(author);
 
ClearAliases<T>(T)
public void ClearAliases<T>(T from) where T : class

Clears all aliases associated with the specified strongly-typed node in the graph.

Parameters

from T
The node whose aliases need to be cleared.

Type Parameters

T
The type of the node. Must be decorated with NodeAttribute.
Method
Graph.FetchFolderContentAsync
public async Task<FetchFolderContentPayload> FetchFolderContentAsync(string folderName, string sourceName, Uri uri)

Fetches the content of a folder from the graph database based on the provided folder name, source name, and URI.

Parameters

folderName
The name of the folder whose content needs to be fetched.
sourceName
The source name associated with the folder.
uri
The URI from which the folder content is fetched.

Returns

An instance of ExistingFilesPayload containing the details of the existing files in the folder.

Examples

 var folderContent = await graph.FetchFolderContentAsync("BooksFolder", "SourceA", new Uri("https://example.com/folder"));
 
Method
Graph.CreateUserAsync
public Task<Node> CreateUserAsync(string userName, string email, string firstName, string lastName, bool isActive = true, bool preferUserNameAsUniqueIdentifer = true, bool cache = false)

Asynchronously creates a new user node in the graph database with the specified details.

Parameters

userName
The username of the user.
email
The email address of the user.
firstName
The first name of the user.
lastName
The last name of the user.

Returns

A Node representing the newly created user.

Examples

 var userNode = await graph.CreateUserAsync("JohnDoe123", "john.doe@example.com", "John", "Doe");
 
Method
Graph.CreateTeamAsync
public Task<Node> CreateTeamAsync(string teamName, string description = null, bool cache = false)

Creates a new team in the graph database with the specified name and optional description.

Parameters

teamName
The name of the team to be created.
description
An optional description of the team.

Returns

A Node representing the created team node.

Examples

 var teamNode = await graph.CreateTeamAsync("Data Science Team", "Handles all data projects");
 
Method
Graph.CreateFolderAsync
public async Task<Node> CreateFolderAsync(string folderName, string source, Uri uri = null, bool initiallyPrivate = false)

Creates a folder node in the graph database with specified properties.

Parameters

folderName
The name of the folder to be created.
source
The source or context of the folder's creation.
uri
Optional URI associated with the folder. This can be used to link the folder to an external resource.
initiallyPrivate
Indicates whether the folder should be marked as private initially. Defaults to false.

Returns

A Node representing the created folder.

Examples

 var folderNode = await graph.CreateFolderAsync("ResearchPapers", "AuthorData", new Uri("https://example.com/folder"), initiallyPrivate: true);
 
 var folderNode = await graph.CreateFolderAsync("Drafts", "EditorWorkspace");
 
Method
Graph.CreateContact
public Node CreateContact(string email, string firstName, string lastName)

Creates a new contact node with the specified email, first name, and last name.

Parameters

email
The unique email identifier of the contact. Must be a valid email format.
firstName
The first name of the contact.
lastName
The last name of the contact.

Returns

A Node representing the contact.

Examples

 var contact = graph.CreateContact("john.doe@example.com", "John", "Doe");
 
Method
Graph.CreateOrganization
public Node CreateOrganization(string domain, string name)

Creates a new organization node in the graph database using the given domain as a unique identifier.

Parameters

domain
The root domain of the organization (e.g., "curiosity.ai"). Must be a valid domain.
name
The name of the organization.

Returns

A Node representing the created or updated organization.

Exceptions

Exception
Thrown if the domain is not a valid website root domain.

Examples

 var organization = graph.CreateOrganization("publisherhouse.com", "Publisher House");
 
Method
Graph.CreateWebPage
public Node CreateWebPage(string url, string title, string textContent, bool renderHTML, string source, string excerpt = null, string author = null)

Creates a web page node in the graph with the provided attributes.

Parameters

url
The unique URL of the web page.
title
The title of the web page.
textContent
The textual content of the web page.
renderHTML
Indicates whether the HTML content of the page should be rendered.
source
The source or origin of the web page.
excerpt
Optional excerpt or snippet from the web page.
author
Optional author of the web page content.

Returns

A new node representing the web page.

Examples

 var webPageNode = graph.CreateWebPage(
 url: "https://example.com/article",
 title: "Graph Databases",
 textContent: "An introduction to graph databases.",
 renderHTML: true,
 source: "https://example.com",
 excerpt: "An introduction...",
 author: "John Doe");
 
Method
Graph.CheckPermissionsChanged
public bool CheckPermissionsChanged(string filePath)

Checks whether the permissions of the specified file have been changed.

Parameters

filePath
The path to the file whose permissions should be checked.

Returns

A boolean value indicating whether the permissions have changed. Returns false on non-Windows operating systems.

Examples

 var permissionsChanged = graph.CheckPermissionsChanged("/path/to/file");
 
Method
Graph.MapPermissionsAsync
public async Task<bool> MapPermissionsAsync(string filePath, Node fileNode)

Maps file access permissions in the graph database for the specified file path and file node.

Parameters

filePath
The file path for which permissions need to be mapped.
fileNode
The graph node representing the file.

Returns

A task representing the asynchronous operation. The task result is a boolean indicating whether the operation was successful (only supported on Windows).

Examples

 var authorNode = Node.FromKey("Author", "john-doe");
 var success = await graph.MapPermissionsAsync("C:/documents/file.txt", authorNode);
 
Method
Graph.UploadFileAndPermissionsAsync
public async Task<Node> UploadFileAndPermissionsAsync(string filePath, string filename, string sourceName, bool checkHash = true, Uri uri = null, bool silent = false)

Uploads a file to the graph database and sets up permissions by mapping it to a graph node.

Parameters

filePath
The path to the file to be uploaded.
filename
The name to assign to the file in the graph database.
sourceName
The source or origin of the file, used for metadata purposes.
checkHash
Indicates whether to verify the file's integrity using a hash. Defaults to true.
uri
Optional URI to associate with the uploaded file.
silent
Doesn't print log messages about the upload

Returns

A Node representing the uploaded file in the graph database.

Examples

 var graph = Graph.Connect("https://example.com", "my-token", "my-connector");
 await graph.InitializeAccessControlAsync("/path/to/cache");
 var fileNode = await graph.UploadFileAndPermissionsAsync("C:/files/myFile.txt", "myFile.txt", "AuthorFileSource");
 
Method
Graph.UploadFileAsync
Overload
UploadFileAsync(string, string, string, bool, Uri, bool, bool)Uploads a file to the graph database and associates it with the specified source. Retries the operation until successful or the defined timeout elapses.
UploadFileAsync(Stream, string, string, bool, Uri, bool, bool)Uploads a file to the graph database and creates a corresponding node with the given attributes.
UploadFileAsync(string, string, string, bool, Uri, bool, bool)
public async Task<Node> UploadFileAsync(string filePath, string fileName, string sourceName, bool checkHash = true, Uri uri = null, bool initiallyPrivate = false, bool silent = false)

Uploads a file to the graph database and associates it with the specified source. Retries the operation until successful or the defined timeout elapses.

Parameters

filePath string
The full file path of the file to be uploaded.
fileName string
The name under which the file should be saved in the graph database.
sourceName string
The source name to associate the uploaded file with.
checkHash bool
Determines whether the file's hash should be validated to prevent duplicates. Defaults to true.
uri Uri
Optional URI to specify the file destination. Defaults to null.
initiallyPrivate bool
Specifies whether the file starts as private. Defaults to false.
silent bool
Doesn't print log messages about the upload

Returns

A task that resolves to the Node representing the uploaded file in the graph database.

Examples

 var node = await graph.UploadFileAsync("C:\\files\\book-cover.jpg", "cover.jpg", "BookSources");
 
UploadFileAsync(Stream, string, string, bool, Uri, bool, bool)
public Task<Node> UploadFileAsync(Stream file, string fileName, string sourceName, bool checkHash = true, Uri uri = null, bool initiallyPrivate = false, bool silent = false)

Uploads a file to the graph database and creates a corresponding node with the given attributes.

Parameters

file Stream
The file stream to upload.
fileName string
The name of the file being uploaded.
sourceName string
The source identifier for the file.
checkHash bool
Indicates whether to check the file hash for duplicates. Default is true.
uri Uri
Optional URI associated with the file. Default is null.
initiallyPrivate bool
Indicates whether the file should be initially private. Default is false.
silent bool
Doesn't print log messages about the upload

Returns

A Node instance representing the uploaded file in the graph database.

Examples

 using var fileStream = File.OpenRead("example.pdf");
 var fileNode = await graph.UploadFileAsync(fileStream, "example.pdf", "source-id");
 
Method
Graph.UploadFileWithIdentifierAsync
public async Task<Node> UploadFileWithIdentifierAsync(Stream file, string fileIdentifier, string displayFileName, string sourceName, bool checkHash = true, bool initiallyPrivate = false)

Uploads a file to the graph database with a unique identifier, associating metadata such as filename and source.

Parameters

file
The file stream to be uploaded. The stream must be readable.
fileIdentifier
A unique identifier for the file.
displayFileName
The name of the file, used for metadata tagging or client display purposes.
sourceName
The source or origin name associated with the file upload.
checkHash
Indicates whether the file hash should be checked before upload. Defaults to true.
initiallyPrivate
Determines whether the uploaded file should initially be private. Defaults to false.

Returns

A Node representing the uploaded file entry in the graph database.

Exceptions

ArgumentNullException
Throws if fileIdentifier, displayFileName, or sourceName is null or empty.

Examples

 using var fileStream = File.OpenRead("book_cover.jpg");
 var fileNode = await graph.UploadFileWithIdentifierAsync(fileStream, "unique-book-1234", "book_cover.jpg", "PublisherA");
 
Method
Graph.UploadFileToFolderAsync
Overload
UploadFileToFolderAsync(Stream, string, string, Node, bool, Uri, bool, bool)Uploads a file to a specified folder in the graph database.
UploadFileToFolderAsync(Uri, string, string, Node, bool, byte[])Uploads a file to a specified folder in the graph database.
UploadFileToFolderAsync(Stream, string, string, Node, bool, Uri, bool, bool)
public async Task<Node> UploadFileToFolderAsync(Stream file, string fileName, string sourceName, Node parentFolderNode, bool checkHash = true, Uri uri = null, bool initiallyPrivate = false, bool inPlace = false)

Uploads a file to a specified folder in the graph database.

Parameters

file Stream
The file stream to be uploaded.
fileName string
The name of the file including its extension.
sourceName string
The source identifier for the file (e.g., application or source system name).
parentFolderNode Node
The folder node where the file will be uploaded to. Must have a valid UID.
checkHash bool
Optional. Whether to validate file integrity using a hash. Default is true.
uri Uri
Optional. A URI representing the original file location, for reference or metadata tracking.
initiallyPrivate bool
Optional. Determines if the file should be marked as private upon upload. Default is false.
inPlace bool

Returns

A new Node that represents the uploaded file within the given folder.

Examples

 var folderNode = Node.FromKey("Folder", "MarketingAssets");
 var fileStream = File.OpenRead("brochure.pdf");
 var uploadedFileNode = await graph.UploadFileToFolderAsync(fileStream, "brochure.pdf", "MarketingTool", folderNode);
 
UploadFileToFolderAsync(Uri, string, string, Node, bool, byte[])
public async Task<Node> UploadFileToFolderAsync(Uri fileUrl, string fileName, string sourceName, Node parentFolderNode, bool initiallyPrivate = false, byte[] sha256Hash = null)

Uploads a file to a specified folder in the graph database.

Parameters

fileUrl Uri
The Url of the file to be uploaded.
fileName string
The name of the file including its extension.
sourceName string
The source identifier for the file (e.g., application or source system name).
parentFolderNode Node
The folder node where the file will be uploaded to. Must have a valid UID.
initiallyPrivate bool
Optional. Determines if the file should be marked as private upon upload. Default is false.
sha256Hash byte[]
Optional. Hash of the file to check first if it needs to be uploaded. Compute with SHA256.Create().ComputeHash(...).

Returns

A new Node that represents the uploaded file within the given folder.

Examples

 var folderNode = Node.FromKey("Folder", "MarketingAssets");
 var fileStream = File.OpenRead("brochure.pdf");
 var uploadedFileNode = await graph.UploadFileToFolderAsync(fileStream, "brochure.pdf", "MarketingTool", folderNode);
 
Method
Graph.GetFileHash
public string GetFileHash(Stream file)

Compute a SHA256 hash for a given input stream file. The stream will be rewinded before and after computing the hash.

Parameters

file
A stream representing the file

Returns

The SHA256 hash of the file content

Method
Graph.TryGetFileNodeAsync
public async Task<Node> TryGetFileNodeAsync(string fileName, string sourceName, byte[] sha256Hash = null)

Try getting the file node after checking if it exists in the graph, and optionally checking if the SHA256 hash is the same

Parameters

fileName
sourceName
sha256Hash
Method
Graph.DeleteFileAsync
public async Task DeleteFileAsync(string fileName, string sourceName)

Deletes a file from the specified source in the graph database.

Parameters

fileName
The name of the file to delete.
sourceName
The source from which the file should be deleted.

Returns

A task that represents the asynchronous delete operation.

Examples

 await graph.DeleteFileAsync("example.txt", "source1");
 
Method
Graph.DeleteFolderAsync
public async Task DeleteFolderAsync(string path, string sourceName)

Deletes a folder from the graph database using the specified path and source name.

Parameters

path
The path of the folder to be deleted.
sourceName
The name of the source for the folder.

Returns

A Task representing the asynchronous operation.

Examples

 await graph.DeleteFolderAsync("/authors/usa", "example-source");
 
Method
Graph.MarkFileAsPrivate
public void MarkFileAsPrivate(Node fileNode)

Marks the specified file node as private by removing the public access edge.

Parameters

fileNode
The file node to mark as private. This node must be of type "_FileEntry".

Exceptions

ArgumentException
Thrown if the provided node is not of type "_FileEntry".

Examples

 var fileNode = Node.FromUID("unique-file-id", "_FileEntry");
 graph.MarkFileAsPrivate(fileNode);
 
Method
Graph.MarkFolderAsPrivate
public void MarkFolderAsPrivate(Node folderNode)

Marks a folder node as private by removing its association with the public access group.

Parameters

folderNode
The folder node to be marked as private. Must be of type "_Folder".

Exceptions

ArgumentException
Thrown if the provided node is not of type "_Folder".

Examples

 var folderNode = Node.FromUID("folder123", "_Folder");
 graph.MarkFolderAsPrivate(folderNode);
 
Method
Graph.AddUserToTeam
public void AddUserToTeam(Node userNode, Node teamNode)

Adds a user node to a team node by creating a unique membership relationship between them.

Parameters

userNode
The node representing the user to be added to the team.
teamNode
The node representing the team to which the user will be added.

Examples

 var user = Node.FromKey("User", "user123");
 var team = Node.FromKey("Team", "teamABC");
 graph.AddUserToTeam(user, team);
 
Method
Graph.AddAdminToTeam
public void AddAdminToTeam(Node userNode, Node teamNode)

Adds a user as an admin to a specified team, creating appropriate edges in the graph database.

Parameters

userNode
The node representing the user to be added as an admin. Must have type "_User".
teamNode
The node representing the team to which the user will be added as an admin. Must have type "_AccessGroup".

Examples

 var adminUser = Node.FromKey("_User", "user123");
 var team = Node.FromKey("_AccessGroup", "team456");
 graph.AddAdminToTeam(adminUser, team);
 
Method
Graph.RemoveAdminFromTeam
public void RemoveAdminFromTeam(Node userNode, Node teamNode)

Removes a user's admin rights on a team by removing the admin edges, while leaving the user's membership intact.

Parameters

userNode
The node representing the user to demote from admin. Must have type "_User".
teamNode
The node representing the team on which the user's admin rights are removed. Must have type "_AccessGroup".

Examples

 var adminUser = Node.FromKey("_User", "user123");
 var team = Node.FromKey("_AccessGroup", "team456");
 graph.RemoveAdminFromTeam(adminUser, team);
 
Method
Graph.RemoveUserFromTeam
public void RemoveUserFromTeam(Node userNode, Node teamNode)

Removes a user from a team by removing all relevant edges between the user node and team node.

Parameters

userNode
The node representing the user to be removed.
teamNode
The node representing the team from which the user will be removed.

Examples

 var userNode = Node.FromKey("_User", "user123");
 var teamNode = Node.FromKey("_AccessGroup", "team456");
 graph.RemoveUserFromTeam(userNode, teamNode);
 
Method
Graph.RestrictAccessToTeam
Overload
RestrictAccessToTeam(Node, Node)Restricts access to a specific node by associating it with a team access group node.
RestrictAccessToTeam<T>(T, Node)Restricts access to a strongly-typed node by associating it with a team access group node.
RestrictAccessToTeam(Node, Node)
public void RestrictAccessToTeam(Node node, Node teamNode)

Restricts access to a specific node by associating it with a team access group node.

Parameters

node Node
The target node to restrict access to.
teamNode Node
The team node representing the access group.

Examples

Create a Book node and restrict its access to a specific team:

 var bookNode = Node.FromKey("Book", "book-key");
 var teamNode = Node.FromKey("_AccessGroup", "team-key");
 graph.RestrictAccessToTeam(bookNode, teamNode);
 

Restrict access of an Author node to a specific team:

 var authorNode = Node.FromKey("Author", "author-key");
 var teamNode = Node.FromKey("_AccessGroup", "team-key");
 graph.RestrictAccessToTeam(authorNode, teamNode);
 
RestrictAccessToTeam<T>(T, Node)
public void RestrictAccessToTeam<T>(T node, Node teamNode) where T : class

Restricts access to a strongly-typed node by associating it with a team access group node.

Parameters

node T
The target node to restrict access to.
teamNode Node
The team node representing the access group.

Type Parameters

T
The type of the node. Must be decorated with NodeAttribute.
Method
Graph.RemoveAccessFromTeam
public void RemoveAccessFromTeam(Node node, Node teamNode)

Removes a team access group as an owner of the specified node, revoking the access previously granted by RestrictAccessToTeam.

Parameters

node
The node from which the team's access is removed.
teamNode
The team node whose access is removed.

Examples

 var bookNode = Node.FromKey("Book", "book-key");
 var teamNode = Node.FromKey("_AccessGroup", "team-key");
 graph.RemoveAccessFromTeam(bookNode, teamNode);
 
Method
Graph.RestrictAccessToUser
Overload
RestrictAccessToUser(Node, Node)Restricts access to the specified node by associating it with a user node as its owner. Creates a bidirectional ownership relationship between the node and the user node.
RestrictAccessToUser<T>(T, Node)Restricts access to a strongly-typed node by associating it with a user node as its owner.
RestrictAccessToUser(Node, Node)
public void RestrictAccessToUser(Node node, Node userNode)

Restricts access to the specified node by associating it with a user node as its owner. Creates a bidirectional ownership relationship between the node and the user node.

Parameters

node Node
The node to restrict access to.
userNode Node
The user node that will own the specified node.

Examples

 var authorNode = Node.FromKey("Author", "JohnDoe");
 var userNode = Node.FromKey("_User", "12345");
 graph.RestrictAccessToUser(authorNode, userNode);
 
RestrictAccessToUser<T>(T, Node)
public void RestrictAccessToUser<T>(T node, Node userNode) where T : class

Restricts access to a strongly-typed node by associating it with a user node as its owner.

Parameters

node T
The node to restrict access to.
userNode Node
The user node that will own the specified node.

Type Parameters

T
The type of the node. Must be decorated with NodeAttribute.
Method
Graph.RemoveAccessFromUser
public void RemoveAccessFromUser(Node node, Node userNode)

Removes a user as an owner of the specified node, revoking the access previously granted by RestrictAccessToUser.

Parameters

node
The node from which the user's access is removed.
userNode
The user node whose access is removed.

Examples

 var authorNode = Node.FromKey("Author", "JohnDoe");
 var userNode = Node.FromKey("_User", "12345");
 graph.RemoveAccessFromUser(authorNode, userNode);
 
Method
Graph.ClearPermissions
Overload
ClearPermissions(Node, IList<Node>)Clears the permissions of the specified node, with an optional exception for specific owner nodes.
ClearPermissions<T>(T, IList<Node>)Clears the permissions of the specified strongly-typed node, with an optional exception for specific owner nodes.
ClearPermissions(Node, IList<Node>)
public void ClearPermissions(Node node, IList<Node> exceptOwners = null)

Clears the permissions of the specified node, with an optional exception for specific owner nodes.

Parameters

node Node
The node for which permissions will be cleared.
exceptOwners IList<Node>
An optional list of owner nodes (of type "_User" or "_AccessGroup") whose permissions will be retained.

Exceptions

ArgumentException
Thrown if any of the provided owner nodes have an invalid type or missing identifier.

Examples

 var bookNode = Node.FromKey("Book", "Book1");
 var authorNode = Node.FromKey("_User", "Author1");
 graph.ClearPermissions(bookNode, new [] { authorNode });
 
 var publisherNode = Node.FromKey("Publisher", "Publisher1");
 graph.ClearPermissions(publisherNode);
 
ClearPermissions<T>(T, IList<Node>)
public void ClearPermissions<T>(T node, IList<Node> exceptOwners = null) where T : class

Clears the permissions of the specified strongly-typed node, with an optional exception for specific owner nodes.

Parameters

node T
The node for which permissions will be cleared.
exceptOwners IList<Node>
An optional list of owner nodes (of type "_User" or "_AccessGroup") whose permissions will be retained.

Type Parameters

T
The type of the node. Must be decorated with NodeAttribute.

Exceptions

ArgumentException
Thrown if any of the provided owner nodes have an invalid type or missing identifier.

Examples

 var author = new Author { Name = "John Doe", Country = "USA" };
 graph.ClearPermissions(author);
 
Method
Graph.LogAsync
public async Task LogAsync(LogLevel logLevel, string message)

Logs a message asynchronously to the graph's logging system.

Parameters

message
The message to be logged.

Returns

A task that represents the asynchronous operation.

Examples

 await graph.LogAsync("Database connected successfully.");
 
Method
Graph.LogManyAsync
public Task LogManyAsync((LogLevel logLevel, string message)[] messages)

Logs a message asynchronously to the graph's logging system.

Parameters

message
The message to be logged.

Returns

A task that represents the asynchronous operation.

Examples

 await graph.LogAsync("Database connected successfully.");
 
Method
Graph.MapAsync
public async Task<Dictionary<Node, string>> MapAsync(string nodeType, string field, int pageSize = 1000)

Retrieves a mapping of nodes to a specified field value for a given node type in the graph database, paged asynchronously.

Parameters

nodeType
The type of the nodes to query (e.g., "Author", "Book").
field
The field name to map (e.g., "Name", "Title").
pageSize
The number of nodes to fetch per page. Default is 1000.

Returns

A task that represents the asynchronous operation. The task result contains a dictionary mapping nodes to their respective field values.

Examples

 var authorNames = await graph.MapAsync("Author", "Name");
 var bookTitles = await graph.MapAsync("Book", "Title", 500);
 
Method
Graph.UploadNewApplicationInterfaceAsync
public async Task UploadNewApplicationInterfaceAsync(string path, int retries = 5, bool autoPatch = false, CancellationToken cancellationToken = default)

Uploads a new application interface to the system from the specified folder contents.

Parameters

path
The file path to the directory containing the application interface.
retries
The number of retry attempts on failure. Default is 5.
autoPatch
If true, won't delete the existing user interface before replacing it with the uploaded one. Default is false.
cancellationToken
A token to monitor for cancellation requests. Allows cancellation of the upload process.

Returns

A task representing the asynchronous operation.

Examples

 var graph = Graph.Connect("https://example.com", "my-token", "my-connector");
 await graph.UploadNewApplicationInterfaceAsync("/path/to/directory");
 
Method
Graph.QueryAsync
public async Task<QueryResults> QueryAsync(Action<IQuery> query)

Executes a query against the graph database asynchronously.

Parameters

query
A delegate to define the query logic using the IQuery interface.

Returns

An instance of QueryResults containing the results of the executed query.

Examples

 var graph = Graph.Connect("https://example.com", "my-token", "my-connector");
 var result = await graph.QueryAsync(q =>
 {
 q.Match(Node.FromKey("Author", "JohnDoe"))
 .Return("Name", "Country");
 });
 
Method
Graph.ClearEmbeddingsIndexAsync
public async Task ClearEmbeddingsIndexAsync(string indexUID)

Clears the embeddings index for the specified index UID in the graph database.

Parameters

indexUID
The unique identifier of the embeddings index to be cleared.

Returns

A task that represents the asynchronous operation.

Examples

 await graph.ClearEmbeddingsIndexAsync("author-index");
 
Method
Graph.AddEmbeddingsToIndexAsync
public async Task AddEmbeddingsToIndexAsync(string indexUID, IEnumerable<NodeAndVector> vectors, int batchSize = 1_000)

Adds a collection of node embeddings to the specified index in batches.

Parameters

indexUID
The unique identifier of the index to add embeddings to.
vectors
A collection of nodes and their associated vector embeddings.
batchSize
The number of embeddings to process per batch. Defaults to 1,000.

Returns

A task representing the asynchronous operation.

Examples

 var authorNode = Node.FromKey("Author", "Author1");
 var embedding = new NodeAndVector(authorNode, new float[] { 1,2,3,4 });
 // Add embeddings to an index:
 await graph.AddEmbeddingsToIndexAsync("author-embeddings", new[] { embedding }, batchSize: 500);
 
Method
Graph.ExportWorkspaceDefinitionAsync
public async Task<Stream> ExportWorkspaceDefinitionAsync()

Exports workspace configuration

Returns

An Stream containing the exported workspace configuration.

Examples

 var graph = Graph.Connect("https://example.com", "my-token", "my-connector");
 var export = await graph.ExportWorkspaceDefinition();
 
Method
Graph.ImportWorkspaceDefinitionsAsync
public async Task<ImportResult> ImportWorkspaceDefinitionsAsync(Stream import)

Imports workspace configuration

Parameters

import
The workspace definition file (.zip) containing the definitions to be imported.

Returns

A task that represents the asynchronous operation, with a result of CustomCodeImportResult indicating the success or failure of the import.

Examples

 var customCodeExport = File.OpenRead("path-to-export-file.zip";
 var importResult = await graph.ImportWorkspaceDefinitionsAsync(customCodeExport);
 

Applies to

Curiosity.Library — 2024.1 and later. See the C# SDK reference for usage patterns and the Schema reference for declaring node and edge types.

© 2026 Curiosity. All rights reserved.