The Curiosity Graph Query Language is a fluent C# interface for traversing and querying the knowledge graph. Two distinct IQuery interfaces exist depending on the context:
Context
How to obtain
Interface
Results
Endpoints / Shell
Q() / Query() global methods
Mosaik.GraphDB.IQuery — full feature set
Return Emit(...) directly, or materialize with AsEnumerable() / ToList() / etc.
Data Connectors
Lambda in await graph.QueryAsync(q => q...)
Curiosity.Library.IQuery — focused subset
QueryResults returned by graph.QueryAsync; use GetEmitted() / GetEmittedCount().
Starting Points
Method
Backend
Library
Notes
StartAt(string nodeType)
✓
✓
All nodes of the given type.
StartAt(Node node)
✓
✓
Start from a specific node. Library uses Node.FromKey().
StartAt(Node[] nodes)
✓
✓
Start from a set of nodes.
StartAt(string nodeType, string[] keys)
—
✓
Start from nodes of a type identified by multiple keys.
Available in both contexts. In endpoints/shell, Emit(...) returned from the endpoint serializes to the HTTP response. In data connectors, it configures what is included in the QueryResults returned by graph.QueryAsync().
Method
Backend
Library
Notes
Emit(string key)
✓
✓
Return matched nodes under a key.
Emit(string key, string[] fields)
✓
✓
Return nodes, restricted to specific fields.
EmitCount(string key)
✓
✓
Return only the count under a key.
EmitWithEdges(string key)
✓
✓
Return nodes with their edge data.
EmitWithEdges(string key, string[] fields)
✓
✓
Return nodes with edges, restricted to specific fields.
EmitWithScores(string name)
✓
—
Return nodes with relevance scores.
EmitUIDs(string name)
✓
—
Return only UIDs.
EmitUIDsWithScores(string name)
✓
—
Return UIDs with scores.
EmitSummary(string name)
✓
—
Return a structural graph summary (shell).
EmitNeighborsSummary(string name)
✓
—
Return an edge-type summary (shell).
Similar(string index, int count, float tolerance)
—
✓
Find similar nodes via a named index.
Similar(IndexTypes?, IndexUID, int count)
✓
—
Find similar nodes via backend index reference.
// Library (data connector) — results via QueryResults
var r = await graph.QueryAsync(q =>
q.StartAt(nameof(Nodes.Device)).Take(10).Emit("N", [nameof(Nodes.Device.Name)]));
var nodes = r.GetEmitted("N");
var r2 = await graph.QueryAsync(q => q.StartAt(nameof(Nodes.Device)).EmitCount("C"));
var count = r2.GetEmittedCount("C");
// Backend (endpoint/shell) — return directly
return Q().StartAt(N.Part.Type).Skip(page * 50).Take(50).Emit();
return Q().StartAt(N.SupportCase.Type).EmitNeighborsSummary();
return Q().EmitSummary();
In-memory materialization (Backend / Endpoints and Shell only)
These methods execute the query and return C# objects. They are not available in the library IQuery.
// Iterate in endpoint code
foreach (var node in Q().StartAt(N.SupportCase.Type).AsEnumerable())
{
var summary = node.GetString(N.SupportCase.Summary);
}
// Materialize to list
var recent = Q().StartAt(N.SupportCase.Type)
.SortByTimestamp(oldestFirst: false)
.Take(20)
.ToList();
// Check existence
bool hasOpen = Q().StartWhereString(N.SupportCase.Type, N.SupportCase.Status, "Open").Any();
Reading Node Properties
In endpoints and shell, nodes returned from AsEnumerable(), ToList(), or inside a Where() predicate expose typed accessors:
Accessor
Type
GetString(key) / GetStringList(key)
string / IReadOnlyList<string>
GetInt(key) / GetIntList(key)
int / IReadOnlyList<int>
GetBool(key) / GetBoolList(key)
bool / IReadOnlyList<bool>
GetFloat(key) / GetFloatList(key)
float / IReadOnlyList<float>
GetDouble(key) / GetDoubleList(key)
double / IReadOnlyList<double>
GetLong(key) / GetLongList(key)
long / IReadOnlyList<long>
GetTime(key) / GetTimeList(key)
Time / IReadOnlyList<Time>
GetUID128(key) / GetUID128List(key)
UID128 / IReadOnlyList<UID128>
node[key]
dynamic
In data connectors, EmittedNode (from QueryResults.GetEmitted()) provides GetField<T>(string field).
Use auto-generated constants to avoid string typos:
foreach (var node in Q().StartAt(N.SupportCase.Type).AsEnumerable())
{
var id = node.GetString(N.SupportCase.Id);
var summary = node.GetString(N.SupportCase.Summary);
var time = node.GetTime(N.SupportCase.Time);
}