Skip to content

Commit c3109ce

Browse files
authored
Login before running schema queries (#106)
related to hypermodeinc/dgraph#4107
1 parent 3efa60e commit c3109ce

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

example_get_schema_test.go

+3-11
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,12 @@ import (
2121
"fmt"
2222
"log"
2323

24-
"github.com/dgraph-io/dgo/v2"
2524
"github.com/dgraph-io/dgo/v2/protos/api"
26-
"google.golang.org/grpc"
2725
)
2826

2927
func Example_getSchema() {
30-
conn, err := grpc.Dial("127.0.0.1:9180", grpc.WithInsecure())
31-
if err != nil {
32-
log.Fatal("While trying to dial gRPC")
33-
}
34-
defer conn.Close()
35-
36-
dc := api.NewDgraphClient(conn)
37-
dg := dgo.NewDgraphClient(dc)
28+
dg, cancel := getDgraphClient()
29+
defer cancel()
3830

3931
op := &api.Operation{}
4032
op.Schema = `
@@ -46,7 +38,7 @@ func Example_getSchema() {
4638
`
4739

4840
ctx := context.Background()
49-
err = dg.Alter(ctx, op)
41+
err := dg.Alter(ctx, op)
5042
if err != nil {
5143
log.Fatal(err)
5244
}

0 commit comments

Comments
 (0)