inthefabric / Weaver

A fluent, strongly-typed Gremlin script generator (for .NET/C#).
www.inthefabric.com
Other
12 stars 0 forks source link

Weaver

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.

Install with NuGet

Basic Usage

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.

Fabric Usage Example

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);

Gremlin Table Support

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.

Titan-Specific Functionality

As of build 0.5.2, Weaver.Titan project provides a variety of functionality that is specific to Titan. This includes:

Graph of the Gods

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.

githalytics.com alpha