Error when running interpreted query: Failed to convert vertex id for parameter

I’m running TG 3.1.2 Docker container and am seeing unexpected behavior with interpreted query.

Interpreted query HTTP call:
curl --user tigergraph:tigergraph -X POST 'http://localhost:14240/gsqlserver/interpreted_query?v1=Foo123&v2=Bar123' -d ' INTERPRET QUERY (VERTEX<Foo> v1, VERTEX<Bar> v2) FOR GRAPH TestGraph { INSERT INTO EDGE FooBar VALUES (v1, v2); PRINT "success"; } '

Output:
{"version":{"edition":"enterprise","api":"v2","schema":0},"error":true,"message":"Failed to convert Bar vertex id for parameter v2","code":"GSQL-2500"}

I expected to see output with “success”.

Here is other evidence that this should work…

  1. The vertices exist:
    curl localhost:9000/graph/TestGraph/vertices/Foo/Foo123
    Output:
    {"version":{"edition":"enterprise","api":"v2","schema":0},"error":false,"message":"","results":[{"v_id":"Foo123","v_type":"Foo","attributes":{"unit_test":"Foo123","Prop1":10}}]}

curl localhost:9000/graph/TestGraph/vertices/Bar/Bar123
Output:
{"version":{"edition":"enterprise","api":"v2","schema":0},"error":false,"message":"","results":[{"v_id":"Bar123","v_type":"Bar","attributes":{"unit_test":"Bar123"}}]}

  1. I can successfully run the query from GraphStudio in interpreted mode:

can run interpreted mode from GraphStudio:
CREATE QUERY addEdgeIfVerticesExist(VERTEX<Foo> v1, VERTEX<Bar> v2) FOR GRAPH TestGraph { INSERT INTO EDGE FooBar VALUES (v1, v2); PRINT "success"; }
Output when run:
[ { "success": "success" } ]

  1. I can also install the above query from GraphStudio and run it successfully via RESTPP endpoint:

curl http://localhost:14240/restpp/query/TestGraph/addEdgeIfVerticesExist?v1=Foo123&v2=Bar123
Output when run:
{"version":{"edition":"enterprise","api":"v2","schema":0},"error":false,"message":"","results":[{"success":"success"}]}

Hi Justin,

Thank you for posting all the details.

Interpreted GSQL in Immediate Mode at this point doesn’t extract the query parameter information. For this reason, the curl command you provided should work after adding vertex type information for each argument:

curl --user tigergraph:tigergraph \
  -X POST 'http://localhost:14240/gsqlserver/interpreted_query?v1[0]=Foo123&v1[0].type=Foo&v2[0]=Bar123&v2[0].type=Bar' \
  -d ' INTERPRET QUERY (VERTEX<Foo> v1, VERTEX<Bar> v2) FOR GRAPH TestGraph { INSERT INTO EDGE FooBar VALUES (v1, v2); PRINT "success"; } '

The usage is similar to Set or bag of VERTEX
(type not pre-specified)
in Complex Type Parameter Passing.

We’ll improve this in the later release.

Best regards,

Jun

Your workaround does work for that specific error, but then I run into type issues for this specific query:

curl --user tigergraph:tigergraph -X POST 'http://localhost:14240/gsqlserver/interpreted_query?v1=Foo123&v1.type=Foo&v2=Bar123&v2.type=Bar' -d '
INTERPRET QUERY (VERTEX v1, VERTEX v2) FOR GRAPH unitTestGraph {
  INSERT INTO EDGE FooBar VALUES (v1, v2);
  PRINT "success";
}
'
{"error":true,"message":"\nType Check Error in query  (TYP-5601): line 4, col 2\nEdge FooBar's valid FROM vertex types don't cover all vertex types, so a\nuniversal vertex type expression cannot be used here.\n","results":""}

CREATE QUERY entityRelationshipKeys2() for graph money1 {
ListAccum @edges;
OrAccum @visited;
vertex v;
SetAccum @@set;
@@set += to_vertex(“6B1B0F103E1F2C16DVUSSN01317813287112”, “Entity”);
Start = @@set;
Start = SELECT s FROM Start:s POST-ACCUM s.@visited = true;
Result = SELECT tgt FROM Start:s-(_:e) ->:tgt ACCUM tgt.@edges += s.@edges, tgt.@edges += e POST-ACCUM tgt.@visited = true;
PRINT Result;
}

CREATE QUERY () FOR GRAPH unitTestGraph {
INSERT INTO EDGE FooBar VALUES (“a”, “b”);
PRINT “success”;
}