Passing in a map[string]string through Gizmo



I’m adding a new query to Gizmo and I want to pass in a map[string]string as a parameter. However, that parameter gets detected as a map[string]interface{}, even though I have surrounded the keys and values with strings. This is what I’m testing:

g.V(“SubjectNode”).OutE(“PredicateNode”, {“ind1”:“val1”}).All()

The second parameter is the map I want to pass in. Is there a different syntax to make Gizmo detect that it is a map[string]string (and not just a generic map[string]interface{})?


I don’t think we support OutE yet, nor the map parameters/filters for nodes or links. If you are interested in full Gremlin implementation (or at least a more compatible one), please express your vote in this thread.


OutE is the query I am adding support for. It seems gizmo.go is recognizing the parameter as a map[string]interface{} though not sure where this is happening. I ended up converting the map[string]interface{} to map[string]string in environ.go and using that in subsequent steps.


I see. I misinterpreted your initial question.

Gizmo is based on a generic JS VM called goja. As any JS VM it has to follow rules of JavaScript language, which means most of the time it cannot determine an exact type of an object. In your sample the type is obvious, but it’s incredibly hard to make it work for a generic case, thus simple VMs like goja keep it simple. As a consequence, any object that is instantiated from JS code will have a most generic object type: map[string]interface{}. And when it is returned to the Go side, you are free to enforce any type checks and conversions that are necessary for underlying type-safe Go code. Until we have a more sophisticated JS VM, there is no way around it.

Hope this answers your question.

Also, feel free to send a PR if you considering to contribute your work to the project.


Ah okay that makes sense. Yes, I’ll be sending a PR as well. Just waiting on #634 and #635 since these changes build on them.