Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ sch := `
email: string @index(exact) @unique .
age: int .
`
err := client.SetSchema(context.TODO(), dgo.RootNamespace, sch)
err := client.SetSchema(context.TODO(), sch)
// Handle error
```

Expand All @@ -159,7 +159,7 @@ mutationDQL := `{
_:alice <age> "29" .
}
}`
resp, err := client.RunDQL(context.TODO(), dgo.RootNamespace, mutationDQL)
resp, err := client.RunDQL(context.TODO(), mutationDQL)
// Handle error
// Print map of blank UIDs
fmt.Printf("%+v\n", resp.Uids)
Expand All @@ -177,7 +177,7 @@ queryDQL := `{
age
}
}`
resp, err := client.RunDQL(context.TODO(), dgo.RootNamespace, queryDQL)
resp, err := client.RunDQL(context.TODO(), queryDQL)
// Handle error
fmt.Printf("%s\n", resp.Json)
```
Expand All @@ -195,7 +195,7 @@ queryDQL = `query Alice($name: string) {
}
}`
vars := map[string]string{"$name": "Alice"}
resp, err := client.RunDQLWithVars(context.TODO(), dgo.RootNamespace, queryDQL, vars)
resp, err := client.RunDQLWithVars(context.TODO(), queryDQL, vars)
// Handle error
fmt.Printf("%s\n", resp.Json)
```
Expand All @@ -212,7 +212,7 @@ queryDQL := `{
age
}
}`
resp, err := client.RunDQL(context.TODO(), dgo.RootNamespace, queryDQL, dgo.WithBestEffort())
resp, err := client.RunDQL(context.TODO(), queryDQL, dgo.WithBestEffort())
// Handle error
fmt.Printf("%s\n", resp.Json)
```
Expand All @@ -229,7 +229,7 @@ queryDQL := `{
age
}
}`
resp, err := client.RunDQL(context.TODO(), dgo.RootNamespace, queryDQL, dgo.WithReadOnly())
resp, err := client.RunDQL(context.TODO(), queryDQL, dgo.WithReadOnly())
// Handle error
fmt.Printf("%s\n", resp.Json)
```
Expand All @@ -246,7 +246,7 @@ queryDQL := `{
age
}
}`
resp, err = client.RunDQL(context.TODO(), dgo.RootNamespace, queryDQL, dgo.WithResponseFormat(api_v2.RespFormat_RDF))
resp, err = client.RunDQL(context.TODO(), queryDQL, dgo.WithResponseFormat(api_v2.RespFormat_RDF))
// Handle error
fmt.Printf("%s\n", resp.Rdf)
```
Expand All @@ -267,7 +267,7 @@ upsertQuery := `upsert {
}
}
}`
resp, err := client.RunDQL(context.TODO(), dgo.RootNamespace, upsertQuery)
resp, err := client.RunDQL(context.TODO(), upsertQuery)
// Handle error
fmt.Printf("%s\n", resp.Json)
fmt.Printf("%+v\n", resp.Uids)
Expand All @@ -287,7 +287,7 @@ upsertQuery := `upsert {
}
}
}`
resp, err := client.RunDQL(context.TODO(), dgo.RootNamespace, upsertQuery)
resp, err := client.RunDQL(context.TODO(), upsertQuery)
// Handle error
fmt.Printf("%s\n", resp.Json)
```
Expand All @@ -306,7 +306,7 @@ _, err := client.CreateNamespace(context.TODO())
To drop a namespace:

```go
_, err := client.DropNamespace(context.TODO())
err := client.DropNamespace(context.TODO())
// Handle error
```

Expand Down Expand Up @@ -514,7 +514,7 @@ fmt.Printf("%s\n", resp.Json)

### Query with RDF response

You can get query result as a RDF response by calling `txn.QueryRDF`. The response would contain a
You can get query result as an RDF response by calling `txn.QueryRDF`. The response would contain a
`Rdf` field, which has the RDF encoded result.

**Note:** If you are querying only for `uid` values, use a JSON format response.
Expand Down
7 changes: 3 additions & 4 deletions open.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func WithSkipTLSVerify() ClientOption {
}
}

// WithSystemCertPool will use the system cert pool and setup a TLS connection with Dgraph cluster.
// WithSystemCertPool will use the system cert pool and set up a TLS connection with Dgraph cluster.
func WithSystemCertPool() ClientOption {
return func(o *clientOptions) error {
pool, err := x509.SystemCertPool()
Expand All @@ -105,7 +105,6 @@ func WithNamespace(nsID uint64) ClientOption {
}

// WithACLCreds will use the provided username and password for ACL authentication.
// If namespace is not provided, it logs into the galaxy namespace.
func WithACLCreds(username, password string) ClientOption {
return func(o *clientOptions) error {
o.username = username
Expand Down Expand Up @@ -220,15 +219,15 @@ func Open(connStr string) (*Dgraph, error) {
}

// NewClient creates a new Dgraph client for a single endpoint.
// If ACL connection options are present, an login attempt is made
// If ACL connection options are present, a login attempt is made
// using the supplied credentials.
func NewClient(endpoint string, opts ...ClientOption) (*Dgraph, error) {
return NewRoundRobinClient([]string{endpoint}, opts...)
}

// NewRoundRobinClient creates a new Dgraph client for a list
// of endpoints. It will round robin among the provided endpoints.
// If ACL connection options are present, an login attempt is made
// If ACL connection options are present, a login attempt is made
// using the supplied credentials.
func NewRoundRobinClient(endpoints []string, opts ...ClientOption) (*Dgraph, error) {
co := &clientOptions{}
Expand Down
Loading