There is simply no such API in Gremlin. It doesn't have a step that can accept GraphSON or a Dictionary
(Map
in Java) to natively convert it to property()
steps. There has been considerable discussion on this topic in the TinkerPop community over the years as the user convenience of a such a step is arguably high especially in the context that you describe. Unfortunately, introducing Map
doesn't fit nicely into the API as it would initially appear as it does not properly allow for setting of multi-properties unless the step signature accepted a Map<Object,List<Object>>
(i.e. in Python, a Dictionary
where the key is String
or T
and the value is a List
of arbitrary objects) which is more complex to construct and reason about. Moreover, that API doesn't account well for meta-properties when taken in the general context of how those are set. There are other arguments against it as well but those are the ones that tend to stick out in my mind.
As for a step accepting GraphSON itself (which I suppose would mitigate some of the issue I mentioned above with multi/meta-properties), I don't think that has ever been proposed. I'm not sure how that would work though, as GraphSON is a function of IO operations and the Gremlin language itself simply has never had any knowledge of that. IO is an abstraction far away from Gremlin and I don't know that it would fit in well there. I also think that most users have complained about GraphSON's complexity (dictionaries with embedded lists or lists and so on) and that manually constructing GraphSON is non-trivial and therefore I'd doubt that many would find such an API appealing to them. Multi/meta-properties strike again! :)
I'd also say that TinkerPop is very much against constructing strings of Gremlin. You're forced to do that now in CosmosDB as they don't yet support the bytecode API. With that support (something they are working on), you will no longer submit Gremlin as a String
value but instead write Gremlin in your favorite native language (in your case Python). So, developing paths that further encourage users to "construct strings", of any sort, GraphSON or Gremlin, will probably be discouraged.
Now, in Python, you could build this method yourself as part of a custom Gremlin DSL which would basically take a Dictionary
and convert it to property()
calls. As the logic would be specific to your application, you could account for whatever meta/multi-property issues you may or may not have. You can read more about how to build DSLs here and learn more about patterns for implementing in this blog post series: Part I, Part II, and Part III.
I think we might see this kind of API native to Gremlin in 4.x when there is growing favor of dropping support for multi/meta-properties, but until then there haven't been many good ideas.