Skip to content

Instantly share code, notes, and snippets.

@Ramko9999
Created February 21, 2020 02:32
Show Gist options
  • Save Ramko9999/1be81aa92c07c5ba8e8e71bb2d1adad9 to your computer and use it in GitHub Desktop.
Save Ramko9999/1be81aa92c07c5ba8e8e71bb2d1adad9 to your computer and use it in GitHub Desktop.
/*
Calling Queries
*/
Map result = await client.callQuery("QUERY NAME", "ARGUMENTS");
/*
The Arguments is essentially the parameters for the TigerGraph query.
For example, consider I wrote a Query called "findPhones" which returns all the phones
belonging to a person.
findPhones(Vertex<Person> person)
Here is how I would call it:
*/
Vertex source = Vertex("Person", "1");
Map result = await client.callQuery("findPhones", {"person": source.id});
/*
When inputting a Vertex for a paramater, we can just include the id of the vertex instead of
passing in the whole vertex object */
/*
If we have a Set as a paramater for teh query, we can simply pass in a list for it.
For example, suppose I had a query called "findCommonFriends" which takes in a set of friends
and returns everyone who is friends with all of them
findCommonFriends(Set<Vertex<Person>> people)
Here is how I would call it:
*/
Vertex v1 = Vertex("Person", "1");
Vertex v2 = Vertex("Person", "67");
Vertex v3 = Vertex("Person", "89");
Map result = await client.callQuery("findCommonFriends", {"people": [v1.id, v2.id, v3.id]});
/*
Furthermore, the JSON objects that are passed will automatically be encoded as Strings
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment