Skip to content

Commit 261d1c2

Browse files
authored
release: update dgo module from v200 to v210 (#148)
Upgrades module path from v200 to v210. Note that there is nothing BREAKING in this version. All the changes are backward compatible. We have added a few new APIs since v200.03.0 release. DialSlashEndpoint and few more related to auth/slash (these are deprecated and will be removed in later releases) LoginIntoNamespace Relogin GetJwt This PR additionally: Updates the README with Login example. Add deprecation comment for DialSlash* APIs
1 parent 95bfd74 commit 261d1c2

13 files changed

+50
-22
lines changed

README.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@ to understand how to run and work with Dgraph.
3333
Depending on the version of Dgraph that you are connecting to, you will have to
3434
use a different version of this client and their corresponding import paths.
3535

36-
Dgraph version | dgo version | dgo import path |
37-
--------------- | ----------- | ------------------------------- |
38-
dgraph 1.0.X | dgo 1.X.Y | "github.com/dgraph-io/dgo" |
39-
dgraph 1.1.X | dgo 2.X.Y | "github.com/dgraph-io/dgo/v2" |
40-
dgraph 20.03.0 | dgo 200.03.0| "github.com/dgraph-io/dgo/v200" |
36+
Dgraph version | dgo version | dgo import path |
37+
--------------- | ----------- | ------------------------------- |
38+
dgraph 1.0.X | dgo 1.X.Y | "github.com/dgraph-io/dgo" |
39+
dgraph 1.1.X | dgo 2.X.Y | "github.com/dgraph-io/dgo/v2" |
40+
dgraph 20.03.0 | dgo 200.03.0 | "github.com/dgraph-io/dgo/v200" |
41+
dgraph 20.07.0 | dgo 200.03.0 | "github.com/dgraph-io/dgo/v200" |
42+
dgraph 20.11.0 | dgo 200.03.0 | "github.com/dgraph-io/dgo/v200" |
43+
dgraph 21.03.0 | dgo 210.03.0 | "github.com/dgraph-io/dgo/v210" |
4144

4245
Note: One of the most important API breakages from dgo v1 to v2 is in
4346
the function `dgo.Txn.Mutate`. This function returns an `*api.Assigned`
@@ -65,6 +68,27 @@ defer conn.Close()
6568
dgraphClient := dgo.NewDgraphClient(api.NewDgraphClient(conn))
6669
```
6770

71+
### Login into a namespace
72+
73+
If your server has Access Control Lists enabled (Dgraph v1.1 or above), the client must be
74+
logged in for accessing data. Use `Login` endpoint:
75+
76+
Calling login will obtain and remember the access and refresh JWT tokens. All subsequent operations
77+
via the logged in client will send along the stored access token.
78+
79+
```go
80+
err := dgraphClient.Login(ctx, "user", "passwd")
81+
// Check error
82+
```
83+
84+
If your server additionally has namespaces (Dgraph v21.03 or above), use the
85+
`LoginIntoNamespace` API.
86+
87+
```go
88+
err := dgraphClient.LoginIntoNamespace(ctx, "user", "passwd", 0x10)
89+
// Check error
90+
```
91+
6892
### Altering the database
6993

7094
To set the schema, create an instance of `api.Operation` and use the `Alter` endpoint.

RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ git push origin <new tag>
2020

2121
2. Change all the import paths to import `v<new major version>`.
2222

23-
For example, current import path is `"github.com/dgraph-io/dgo/v200"`.
23+
For example, if the current import path is `"github.com/dgraph-io/dgo/v200"`.
2424
When we release v201.07.0, we would replace the import paths to `"github.com/dgraph-io/dgo/v201"`.
2525

2626
3. Update [Supported Version](https://github.com/dgraph-io/dgo/#supported-versions).

acl_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424

2525
"github.com/stretchr/testify/require"
2626

27-
"github.com/dgraph-io/dgo/v200"
28-
"github.com/dgraph-io/dgo/v200/protos/api"
27+
"github.com/dgraph-io/dgo/v210"
28+
"github.com/dgraph-io/dgo/v210/protos/api"
2929
)
3030

3131
var (

client.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"strings"
2626
"sync"
2727

28-
"github.com/dgraph-io/dgo/v200/protos/api"
28+
"github.com/dgraph-io/dgo/v210/protos/api"
2929
"google.golang.org/grpc"
3030
"google.golang.org/grpc/codes"
3131
"google.golang.org/grpc/credentials"
@@ -66,6 +66,8 @@ func NewDgraphClient(clients ...api.DgraphClient) *Dgraph {
6666
return dg
6767
}
6868

69+
// DialSlashEndpoint is deprecated and will be removed in v21.07 release. For more details,
70+
// see: https://discuss.dgraph.io/t/regarding-slash-cloud-dgraph-endpoints-in-the-clients/13492
6971
// DialSlashEndpoint creates a new TLS connection to a Slash GraphQL or Slash Enterprise backend
7072
// It requires the backend endpoint as well as the api key
7173
func DialSlashEndpoint(endpoint, key string) (*grpc.ClientConn, error) {
@@ -90,6 +92,8 @@ func DialSlashEndpoint(endpoint, key string) (*grpc.ClientConn, error) {
9092
)
9193
}
9294

95+
// DialSlashGraphQLEndpoint is deprecated and will be removed in v21.07 release. For more details,
96+
// see: https://discuss.dgraph.io/t/regarding-slash-cloud-dgraph-endpoints-in-the-clients/13492
9397
// DialSlashGraphQLEndpoint is deprecated, as it leaks GRPC connections.
9498
// Please use DialSlashEndpoint instead
9599
func DialSlashGraphQLEndpoint(endpoint, key string) (*Dgraph, error) {

errors_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222

2323
"github.com/stretchr/testify/require"
2424

25-
"github.com/dgraph-io/dgo/v200"
26-
"github.com/dgraph-io/dgo/v200/protos/api"
25+
"github.com/dgraph-io/dgo/v210"
26+
"github.com/dgraph-io/dgo/v210/protos/api"
2727
)
2828

2929
func TestTxnErrFinished(t *testing.T) {

example_get_schema_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"fmt"
2222
"log"
2323

24-
"github.com/dgraph-io/dgo/v200/protos/api"
24+
"github.com/dgraph-io/dgo/v210/protos/api"
2525
)
2626

2727
func Example_getSchema() {

example_set_object_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"log"
88
"time"
99

10-
"github.com/dgraph-io/dgo/v200/protos/api"
10+
"github.com/dgraph-io/dgo/v210/protos/api"
1111
)
1212

1313
type School struct {

examples_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
"strings"
2525
"time"
2626

27-
"github.com/dgraph-io/dgo/v200"
28-
"github.com/dgraph-io/dgo/v200/protos/api"
27+
"github.com/dgraph-io/dgo/v210"
28+
"github.com/dgraph-io/dgo/v210/protos/api"
2929
"google.golang.org/grpc"
3030
)
3131

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/dgraph-io/dgo/v200
1+
module github.com/dgraph-io/dgo/v210
22

33
go 1.12
44

testutil_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"github.com/pkg/errors"
2929
"github.com/stretchr/testify/require"
3030

31-
"github.com/dgraph-io/dgo/v200/protos/api"
31+
"github.com/dgraph-io/dgo/v210/protos/api"
3232
)
3333

3434
// LoginParams stores the information needed to perform a login request.

0 commit comments

Comments
 (0)