Q:

Spring mongodb: Aggregation unable to specify graphLookup.maxDepth

I recently updated to the latest spring mongodb 1.10 to try out the new $graphLookup aggregator. However, I can't seem to specify all the parameters for the graphLookup. 
Specifically I can set startWith, connectFrom, and connectTo successfully, but as, and maxDepth don't seem to be visible.
This works: 
Aggregation.graphLookup("relationships")
        .startWith("destination")
        .connectFrom("destination")
        .connectTo("source")
    ;

This does not:
Aggregation.graphLookup("relationships")
        .startWith("destination")
        .connectFrom("destination")
        .connectTo("source")
        .maxDepth("2")
        .as("relationshipGraph")
    ;

Looking at the spring source code it seems the class returned by connectTo GraphLookupOperationBuilder is static and final. 
Is there another way to set maxDepth, or is this a bug?

A:

This is still a release candidate version but looks like it is a bug. You can use the below workaround using AggregationOperation which lets you create a aggregation pipeline.
 AggregationOperation aggregation = new AggregationOperation() {
            @Override
            public DBObject toDBObject(AggregationOperationContext aggregationOperationContext) {
                DBObject graphLookup = new BasicDBObject(
                                "from", "relationships"). append(
                                "startWith", "$destination").append(
                                "connectFromField", "destination").append(
                                "connectToField", "source").append(
                                "maxDepth", 2).append(
                                "as", "relationshipGraph");
                return new BasicDBObject("$graphLookup", graphLookup);
            }
        };

