Skip to content

Commit

Permalink
Updated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
damienstamates committed Jan 25, 2019
1 parent 0a84166 commit d0d7339
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -65,8 +65,8 @@ import (

"go.uber.org/zap"

"github.com/northwesternmutual/grammes/query/traversal"
"github.com/northwesternmutual/grammes/manager"
"github.com/northwesternmutual/grammes/query/token"
"github.com/northwesternmutual/grammes"
)
```

Expand Down
31 changes: 31 additions & 0 deletions grammes_test.go
Expand Up @@ -33,6 +33,37 @@ func Example_newClient() {
log.Fatalf("Error while creating client: %s\n", err.Error())
}

_ = client
}

func Example_executeQuery() {
// Creates a new client with the localhost IP.
client, err := grammes.DialWithWebSocket("ws://127.0.0.1:8182")
if err != nil {
log.Fatalf("Error while creating client: %s\n", err.Error())
}

// Create a graph traversal to use when querying.
g := grammes.Traversal()

// Executing a basic query to add a vertex to the graph
// with label "testingVertex" and property "name" that equals "damien"
res, err := client.ExecuteQuery(g.AddV("testingVertex").Property("name", "damien"))
if err != nil {
log.Fatalf("Querying error: %s\n", err.Error())
}

// Print out the result as a string
log.Println(string(res))
}

func Example_executeStringQuery() {
// Creates a new client with the localhost IP.
client, err := grammes.DialWithWebSocket("ws://127.0.0.1:8182")
if err != nil {
log.Fatalf("Error while creating client: %s\n", err.Error())
}

// Executing a basic query to assure that the client is working.
res, err := client.ExecuteStringQuery("1+3")
if err != nil {
Expand Down

0 comments on commit d0d7339

Please sign in to comment.