ArangoDB-Community / arangodb-tinkerpop-provider

An implementation of the Tinkerpop OLTP Provider for ArangoDB
Apache License 2.0
84 stars 16 forks source link

Add new "kind" of edges #59

Closed MartinBrugnara closed 4 years ago

MartinBrugnara commented 4 years ago

Hi all, I have a question, possibly connected to #58 :

How can I create a new edge type once I have created the graph?

Scenario example

Session 1 Define schema and load initial data

ArangoDBConfigurationBuilder builder = new ArangoDBConfigurationBuilder();
builder.graph("MAIN_GRAPH");
builder.withVertexCollection("vertex_t1");
builder.withVertexCollection("vertex_t2");
builder.withEdgeCollection("edge_t1");
g = GraphFactory.open(builder.build());
GraphSONReader.build().create().readGraph(new FileInputStream(new File(ds)), g);

Session 2

builder.graph("MAIN_GRAPH");
builder.withVertexCollection("vertex_t1");
builder.withVertexCollection("vertex_t2");
builder.withEdgeCollection("edge_t1");
// --- new code
builder.withEdgeCollection("edge_t2");
// --- end new code
g = GraphFactory.open(builder.build());

Issue & errors

If I try to connect like this I get an error that says Not all declared vertex names appear in the graph. Missing [MAIN_GRAPH_edge_t2].

If I do not configure the new edge and then try to add an edge with such label it generates a new error Exception in thread "main" java.lang.IllegalArgumentException: Edge label (edge_t2)not in graph (MAIN_GRAPH) edge collections.

arcanefoam commented 4 years ago

Sadly, the current implementation does not support this scenario. I can imagine that during development the graph schema might evolve and hence a more flexible operation mode thst does not enforce the schema can be handy. I would suggest closing this issue and opening a new one relevant to "add option to relax schema constrains". I don't think it's a difficult change, although it will require a lot of small conditions added throughout. Maybe you will consider attempting a pull request with it?

MartinBrugnara commented 4 years ago

Thank you @arcanefoam for the quick response! I will close this issue and open another one as "feature request".

If this is a small modification it can be a great first contribution opportunity ... unfortunately I cannot take it upon my self at this time.

Cheers, M