Weaver provides a fluent, strongly-typed interface for generating Gremlin scripts (for .NET/C#).
This requires that your graph domain classes use Weaver's custom attributes for vertices, edges, and properties. The Weaver.Titan
package includes additional Titan-specific functionality for creating graph data-types, groups, and indices.
PM> Install-Package Weaver
PM> Install-Package Weaver.Titan
Weaver converts C# code:
myWeaverObj.Graph.V.ExactIndex<User>(x => x.Name, "Zach")
...into Gremlin script:
g.V('U_Na','Zach')
The Gremlin script can also be parameterized (enabled by default) to achieve more efficient query compilation on the database side.
Weaver was built to support the Fabric project, which provides several useful examples of Weaver configuration, setup, and usage.
A slightly-modified example from Fabric code:
IWeaverFuncAs<Member> memAlias;
IWeaverQuery q = myWeaverObj.Graph
.V.ExactIndex<User>(x => x.ArtifactId, 123)
.DefinesMemberList.ToMember
.As(out memAlias)
.InAppDefines.FromApp
.Has(x => x.ArtifactId, WeaverStepHasOp.EqualTo, pApiCtx.AppId)
.Back(memAlias)
.HasMemberTypeAssign.ToMemberTypeAssign
.Has(x => x.MemberTypeId, WeaverStepHasOp.NotEqualTo, (byte)MemberTypeId.None)
.Has(x => x.MemberTypeId, WeaverStepHasOp.NotEqualTo, (byte)MemberTypeId.Invite)
.Has(x => x.MemberTypeId, WeaverStepHasOp.NotEqualTo, (byte)MemberTypeId.Request)
.Back(memAlias)
.ToQuery();
SendGremlinRequest(q.Script, q.Params);
Weaver provides support for the Gremlin table
step. Table columns are defined using Weaver's AsColumn()
step, which support property-selection and customized scripts. Weaver's Table()
step automatically builds the column clousures using the information provided in the AsColumn()
steps.
For more details, see the Weaver Table Support wiki page.
As of build 0.5.2, Weaver.Titan
project provides a variety of functionality that is specific to Titan. This includes:
In the Weaver.Examples
project, the "Graph of the Gods" graph schema is implemented using Weaver's attributes, and some basic traversals are demonstrated. View the code.