tiger_graph 0.0.5

  • Readme
  • Changelog
  • Installing
  • 48

tiger_graph #

A Dart wrapper that streamlines connection between a TigerGraph cloud instance and Flutter. Essentially, all the communication between Flutter and TigerGraph is done through REST. This package is a simply wrapper to remove the redundancy and time of writing http requests manually.

Getting Started #

The main class is GraphClient, and it essentially handles the communication between TigerGraph and your requests. Whenever a GraphClient is initialized, it automatically generates a new auth token to communicate with TigerGraph servers. My recommendation is to have one GraphClient through out the app and access that GraphClient to perform actions.

Getting a Vertex and Edge #


//Server for instance is like this: 'fraud-det.i.tgcloud.us:9000'
GraphClient graphClient = await GraphClient.getInstance({Your Secret}, {Your Graph Name}, {Your Server Name});

/*this is the information about the vertex need to get it. In order to get all vertices of a certain Vertex Type
simply set 'vId': ''
*/

Map vertex = {'vType': 'Person', 'vId': '90'};

//getting the vertex data
Map data = graphClient.getVertex(vertex);

// In order to customize the edges we recieve, we can pass optional args
Map fromVertex = {'vType': 'Person', 'vId': '90'};

//grab all edges stemming from the vertex

Map data = await graphClient.getEdge(fromVertex);

//grab all edges of a certain edge type stemming from the vertex

Map data = await graphClient.getEdge(fromVertex, edgeType: 'LIKES');

//grab the edge based on edgeType and ending vertex

Map toVertex = {'vType': 'Person', 'vId': '76'};
Map data = await graphClient.getEdge(fromVertex, edgeType: 'LIKES', toVertex: toVertex);

Deleting vertices and Edges #


//Deleting is very similar to getting vertices and edges

//TigerGraph handles deleting vertices and edges that do not exist very well, so no errors should occur

Map vertex = {'vType': 'Person', 'vId': '90'};

await graphClient.deleteVertex(vertex); //will give a Future<String> for confirmation

Map fromVertex  = {'vType': 'Person', 'vId': '90'};

//WARNING: this will delete all edges stemming from the fromVertex similar to how getEdge() grabs all edges
// The code will immediately stop that from happening, but if you do want to still delete pass in the optional arg override = 'DELETE'

await graphClient.deleteEdge(fromVertex); //CODE WILL STOP THIS FROM DELETING ALL EDGES

await graphClient.deleteEdge(fromVertex, override:'DELETE'); //CODE WILL DELETE ALL EDGES

//The code below will delete all edges of given edgeType similar to getEdge() gets all edges of given edgeType

await graphClient.deleteEdge(fromVertex, edgeType: 'LIKES');

//The code below will delete the edge between 2 vertices

Map toVertex = {'vType': 'Person', 'vId': '76'};

await graphClient.deleteEdge(fromVertex, edgeType: 'LIKES', toVertex:toVertex);

Upserting Data #


//Typically it is recommend to upsert data with a WriteBatch since it upserts a bunch of data in one request

//For example

final batch = graphClient.createWriteBatch();

//the attrs key is essentially the attributes of the vertex, you can ignore having to provide vId or type
//put in the attrs with the attribute name as key and attribute value as value
Map v1 = {'vType': 'Person', 'vId': '55', 'attrs':{'name': 'Jenny'}};
Map v2 = {'vType': 'Person', 'vId': '51', 'attrs':{'name': 'Peter'}};

batch.upsertVertex(v1);
batch.upsertVertex(v2);

//upserting an edge is similar, must provide the fromVertex, toVertex, edgeName and edge attributes
batch.upsertEdge(v1, v2, 'LIKES', {}); //pass in attributes the same way as we did for vertices

//once ready to post the data commit
await batch.commit();

Calling Written Queries #


//In order to call written queries, simply use the callQuery()

await graphClient.callQuery({you query name}, {your query args});

//the query args is a map of parameters that the query takes
//the parameter name will be the key and the the value that is passed shall be the value in the map

//For example

await graphClient.callQuery("Hello Neighbors", {'personId': '55'});

//The code above will call the written query "Hello Neighbors" with the Vertex<Person> parameter "personId"

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

[0.0.1] - TODO: Add release date. #

  • TODO: Describe initial release.

[0.0.5] - Updated Readmen #

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  tiger_graph: ^0.0.5

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:tiger_graph/tiger_graph.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
5
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
48
Learn more about scoring.

We analyzed this package on Feb 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.8

Health issues and suggestions

Document public APIs. (-1 points)

24 out of 24 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/exceptions.dart. (-0.50 points)

Analysis of lib/exceptions.dart reported 1 hint:

line 12 col 10: This function has a return type of 'String', but doesn't end with a return statement.

Fix lib/tiger_graph.dart. (-0.50 points)

Analysis of lib/tiger_graph.dart reported 1 hint:

line 17 col 10: The value of the field '_graph' isn't used.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and tiger_graph.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
http ^0.12.0+2 0.12.0+4
Transitive dependencies
async 2.4.0
charcode 1.1.3
collection 1.14.11 1.14.12
http_parser 3.1.3
meta 1.1.8
path 1.6.4
pedantic 1.9.0
sky_engine 0.0.99
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test