This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final client = await GraphClient.getInstance("YOUR TOKEN","YOUR GRAPH NAME", "YOUR SERVER INFORMATION"); | |
/* | |
For example, if my domain was "https://flutter-test.i.tgcloud.io:14240/#/home" with my graph name called "demo_graph" | |
Here is what my client paramters would look like | |
*/ | |
String token = "12345678900"; | |
final client = await GraphClient.getInstance(token, "demo_graph", "flutter-test.i.tgcloud.io:9000"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map result = await client.getEdge("SOURCE VERTEX", "EDGE NAME", "TARGET VERTEX (OPTIONAL)"); | |
/* | |
For example, consider I have in Graph Schema the Vertex Person has an Edge to Vertex Phone called "HAS_PHONE" | |
If I wanted to get that edge, here is how that would look. | |
*/ | |
Vertex source = Vertex("Person", "1"); | |
Vertex target = Vertex("Phone", "612-391-2389"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Deleting a Vertex is the same as getting Vertices. | |
*/ | |
await client.deleteVertex("THE VERTEX OBJECT"); | |
/* | |
If I wanted to delete a Vertex of type "Person" with id "91", here is | |
how I would do it: | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Here is how we would delete the "HAS_PHONE" edge shown earlier. | |
*/ | |
Vertex source = Vertex("Person", "1"); | |
Vertex target = Vertex("Phone", "612-391-2389"); | |
String edge = "HAS_PHONE"; | |
await client.deleteEdge(source, edge, target); | |
/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This is strictly for upserting a couple of Vertices or Edges. | |
If you want to upsert many Vertices or Edges in bulk, we will cover that in | |
the next code snippet. | |
*/ | |
/* | |
Here is the format for the Upserting Vertices | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
To create a write batch, simply call GraphClient.createWriteBatch() | |
*/ | |
final writeBatch = client.createWriteBatch(); | |
/* | |
We can essentially upsert as many vertices or edges as we want, and then when we are ready, | |
we can send all our upserted vertices and edges in one request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
We can do many more vertex attribute operations using the FieldValue class. | |
*/ | |
//For Incrementing a Number Vertex | |
FieldValue.increment("THE NUMBER"); | |
//Doing the "OR" operation or "||" on boolean values with new value | |
FieldValue.logicalOr("THE BOOLEAN"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
GETTING VERTEX DATA | |
*/ | |
Map result = await client.getVertex(Vertex("product", "BELTS")); | |
/*The return object will be the Json decoded standard tigerGraph response, thus it will be a map. | |
For example, here is what result will be: | |
{version: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Before, we attempt to retrieve any vertices, we must first create a Vertex() object that we can pass in as a paramter. | |
*/ | |
Vertex v1 = Vertex("VERTEX TYPE", "VERTEX ID", "VERTEX ATTRIBUTES (OPTIONAL)"); | |
Vertex siteVertex = Vertex("site", "site91"); //example |
OlderNewer