Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: "query <graph> <query expression>", Short: "Query a graph", Long: `Query a graph. Example: grip query example-graph 'V().hasLabel("Variant").out().limit(5)'`, Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { vm := goja.New() us, err := underscore.Asset("underscore.js") if err != nil { return fmt.Errorf("failed to load underscore.js") } if _, err := vm.RunString(string(us)); err != nil { return err } gripqlString, err := gripqljs.Asset("gripql.js") if err != nil { return fmt.Errorf("failed to load gripql.js") } if _, err := vm.RunString(string(gripqlString)); err != nil { return err } queryString := args[1] val, err := vm.RunString(queryString) if err != nil { return err } queryJSON, err := json.Marshal(val) if err != nil { return err } query := gripql.GraphQuery{} err = protojson.Unmarshal(queryJSON, &query) if err != nil { return err } query.Graph = args[0] conn, err := gripql.Connect(rpc.ConfigWithDefaults(host), true) if err != nil { return err } res, err := conn.Traversal(&query) if err != nil { return err } for row := range res { rowString, _ := protojson.Marshal(row) fmt.Printf("%s\n", rowString) } return nil }, }
Cmd is the declaration of the command line
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.