public static IGremlinQueryEnvironment UseCosmosDb(this IGremlinQueryEnvironment env, Func <ICosmosDbConfigurationBuilder, IGremlinQueryEnvironmentBuilder> transformation) { return(env .ConfigureFeatureSet(featureSet => featureSet .ConfigureGraphFeatures(_ => GraphFeatures.Transactions | GraphFeatures.Persistence | GraphFeatures.ConcurrentAccess) .ConfigureVariableFeatures(_ => VariableFeatures.BooleanValues | VariableFeatures.IntegerValues | VariableFeatures.ByteValues | VariableFeatures.DoubleValues | VariableFeatures.FloatValues | VariableFeatures.IntegerValues | VariableFeatures.LongValues | VariableFeatures.StringValues) .ConfigureVertexFeatures(_ => VertexFeatures.RemoveVertices | VertexFeatures.MetaProperties | VertexFeatures.AddVertices | VertexFeatures.MultiProperties | VertexFeatures.StringIds | VertexFeatures.UserSuppliedIds | VertexFeatures.AddProperty | VertexFeatures.RemoveProperty) .ConfigureVertexPropertyFeatures(_ => VertexPropertyFeatures.StringIds | VertexPropertyFeatures.UserSuppliedIds | VertexPropertyFeatures.RemoveProperty | VertexPropertyFeatures.BooleanValues | VertexPropertyFeatures.ByteValues | VertexPropertyFeatures.DoubleValues | VertexPropertyFeatures.FloatValues | VertexPropertyFeatures.IntegerValues | VertexPropertyFeatures.LongValues | VertexPropertyFeatures.StringValues) .ConfigureEdgeFeatures(_ => EdgeFeatures.AddEdges | EdgeFeatures.RemoveEdges | EdgeFeatures.StringIds | EdgeFeatures.UserSuppliedIds | EdgeFeatures.AddProperty | EdgeFeatures.RemoveProperty) .ConfigureEdgePropertyFeatures(_ => EdgePropertyFeatures.Properties | EdgePropertyFeatures.BooleanValues | EdgePropertyFeatures.ByteValues | EdgePropertyFeatures.DoubleValues | EdgePropertyFeatures.FloatValues | EdgePropertyFeatures.IntegerValues | EdgePropertyFeatures.LongValues | EdgePropertyFeatures.StringValues)) .ConfigureOptions(options => options .SetValue(GremlinqOption.VertexProjectionSteps, ImmutableList <Step> .Empty) .SetValue(GremlinqOption.EdgeProjectionSteps, ImmutableList <Step> .Empty)) .ConfigureSerializer(serializer => serializer .ConfigureFragmentSerializer(fragmentSerializer => fragmentSerializer .Override <CosmosDbKey>((key, env, overridden, recurse) => recurse.Serialize( key.PartitionKey != null ? new[] { key.PartitionKey, key.Id } : (object)key.Id, env)) .Override <HasKeyStep>((step, env, overridden, recurse) => { return step.Argument is P p && (!p.OperatorName.Equals("eq", StringComparison.OrdinalIgnoreCase)) ? recurse.Serialize(new WhereTraversalStep(new Step[] { KeyStep.Instance, new IsStep(p) }), env) : overridden(step, env, recurse); }) .Override <SkipStep>((step, env, overridden, recurse) => recurse.Serialize(new RangeStep(step.Count, -1, step.Scope), env)) .Override <LimitStep>((step, env, overridden, recurse) => { // Workaround for https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/33998623-cosmosdb-s-implementation-of-the-tinkerpop-dsl-has return step.Count <= int.MaxValue ? overridden(step, env, recurse) : throw new ArgumentOutOfRangeException(nameof(step), "CosmosDb doesn't currently support values for 'Limit' outside the range of a 32-bit-integer."); }) .Override <TailStep>((step, env, overridden, recurse) => { // Workaround for https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/33998623-cosmosdb-s-implementation-of-the-tinkerpop-dsl-has return step.Count <= int.MaxValue ? overridden(step, env, recurse) : throw new ArgumentOutOfRangeException(nameof(step), "CosmosDb doesn't currently support values for 'Tail' outside the range of a 32-bit-integer."); }) .Override <RangeStep>((step, env, overridden, recurse) => { // Workaround for https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/33998623-cosmosdb-s-implementation-of-the-tinkerpop-dsl-has return step.Lower <= int.MaxValue && step.Upper <= int.MaxValue ? overridden(step, env, recurse) : throw new ArgumentOutOfRangeException(nameof(step), "CosmosDb doesn't currently support values for 'Range' outside the range of a 32-bit-integer."); }) .Override <long>((l, env, overridden, recurse) => { // Workaround for https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/33998623-cosmosdb-s-implementation-of-the-tinkerpop-dsl-has return recurse.Serialize((int)l, env); })) .ToGroovy()) .ConfigureWebSocket(builder => transformation(new CosmosDbConfigurationBuilder(builder.SetSerializationFormat(SerializationFormat.GraphSonV2)))) .StoreTimeSpansAsNumbers()); }