@@ -14,10 +14,9 @@ repository.**
1414## Table of contents
1515
1616- [ Supported Versions] ( #supported-versions )
17- - [ v2 APIs] ( #v2 -apis )
17+ - [ New APIs in v25 ] ( #new -apis-in-v25 )
1818 - [ Connection Strings] ( #connection-strings )
1919 - [ Advanced Client Creation] ( #advanced-client-creation )
20- - [ Connecting To Dgraph Cloud] ( #connecting-to-dgraph-cloud )
2120 - [ Dropping All Data] ( #dropping-all-data )
2221 - [ Set Schema] ( #set-schema )
2322 - [ Running a Mutation] ( #running-a-mutation )
@@ -30,9 +29,8 @@ repository.**
3029 - [ Running a Conditional Upsert] ( #running-a-conditional-upsert )
3130 - [ Creating a New Namespace] ( #creating-a-new-namespace )
3231 - [ Dropping a Namespace] ( #dropping-a-namespace )
33- - [ Rename a Namespace] ( #rename-a-namespace )
3432 - [ List All Namespaces] ( #list-all-namespaces )
35- - [ v1 APIs] ( #v1 -apis )
33+ - [ Existing APIs] ( #existing -apis )
3634 - [ Creating a Client] ( #creating-a-client )
3735 - [ Login into a namespace] ( #login-into-a-namespace )
3836 - [ Altering the database] ( #altering-the-database )
@@ -59,10 +57,7 @@ version of this client and their corresponding import paths.
5957| dgraph 25.X.Y | dgo 240.X.Y | "github.com/dgraph-io/dgo/v240" |
6058| dgraph 25.X.Y | dgo 250.X.Y | "github.com/dgraph-io/dgo/v250" |
6159
62- ## v2 APIs
63-
64- These are _ experimental_ APIs that we are still making changes to. If you have any feedback, please
65- let us know either on Discord or GitHub.
60+ ## New APIs in v25
6661
6762### Connection Strings
6863
@@ -129,37 +124,12 @@ defer client.Close()
129124// Use the client
130125```
131126
132- ### Connecting To Dgraph Cloud
133-
134- You can use either ` Open ` or ` NewClient ` to connect to Dgraph Cloud. Note ` DialCloud ` is marked
135- deprecated and will be removed in later versions.
136-
137- Using ` Open ` with a connection string:
138-
139- ``` go
140- client , err := dgo.Open (" dgraph://foo-bar.grpc.cloud.dgraph.io:443?sslmode=verify-ca&apikey=AValidKeYFromDgrAPHCloud=" )
141- // Check error
142- defer client.Close ()
143- ```
144-
145- Using ` NewClient ` :
146-
147- ``` go
148- client , err := dgo.NewClient (" foo-bar.grpc.cloud.dgraph.io:443" ,
149- dgo.WithDgraphAPIKey (" AValidKeYFromDgrAPHCloud=" ),
150- dgo.WithSystemCertPool (),
151- )
152- // Check error
153- defer client.Close ()
154- ```
155-
156127### Dropping All Data
157128
158- In order to drop all data in the Dgraph Cluster and start fresh, use the ` DropAllNamespaces `
159- function.
129+ In order to drop all data in the Dgraph Cluster and start fresh, use the ` DropAll ` function.
160130
161131``` go
162- err := client.DropAllNamespaces (context.TODO ())
132+ err := client.DropAll (context.TODO ())
163133// Handle error
164134```
165135
@@ -192,7 +162,7 @@ mutationDQL := `{
192162resp , err := client.RunDQL (context.TODO (), dgo.RootNamespace , mutationDQL)
193163// Handle error
194164// Print map of blank UIDs
195- fmt.Printf (" %+v \n " , resp.BlankUids )
165+ fmt.Printf (" %+v \n " , resp.Uids )
196166```
197167
198168### Running a Query
@@ -209,7 +179,7 @@ queryDQL := `{
209179}`
210180resp , err := client.RunDQL (context.TODO (), dgo.RootNamespace , queryDQL)
211181// Handle error
212- fmt.Printf (" %s \n " , resp.QueryResult )
182+ fmt.Printf (" %s \n " , resp.Json )
213183```
214184
215185### Running a Query With Variables
@@ -227,7 +197,7 @@ queryDQL = `query Alice($name: string) {
227197vars := map [string ]string {" $name" : " Alice" }
228198resp , err := client.RunDQLWithVars (context.TODO (), dgo.RootNamespace , queryDQL, vars)
229199// Handle error
230- fmt.Printf (" %s \n " , resp.QueryResult )
200+ fmt.Printf (" %s \n " , resp.Json )
231201```
232202
233203### Running a Best Effort Query
@@ -244,7 +214,7 @@ queryDQL := `{
244214}`
245215resp , err := client.RunDQL (context.TODO (), dgo.RootNamespace , queryDQL, dgo.WithBestEffort ())
246216// Handle error
247- fmt.Printf (" %s \n " , resp.QueryResult )
217+ fmt.Printf (" %s \n " , resp.Json )
248218```
249219
250220### Running a ReadOnly Query
@@ -261,7 +231,7 @@ queryDQL := `{
261231}`
262232resp , err := client.RunDQL (context.TODO (), dgo.RootNamespace , queryDQL, dgo.WithReadOnly ())
263233// Handle error
264- fmt.Printf (" %s \n " , resp.QueryResult )
234+ fmt.Printf (" %s \n " , resp.Json )
265235```
266236
267237### Running a Query with RDF Response
@@ -278,7 +248,7 @@ queryDQL := `{
278248}`
279249resp, err = client.RunDQL (context.TODO (), dgo.RootNamespace , queryDQL, dgo.WithResponseFormat (api_v2.RespFormat_RDF ))
280250// Handle error
281- fmt.Printf (" %s \n " , resp.QueryResult )
251+ fmt.Printf (" %s \n " , resp.Rdf )
282252```
283253
284254### Running an Upsert
@@ -299,8 +269,8 @@ upsertQuery := `upsert {
299269}`
300270resp , err := client.RunDQL (context.TODO (), dgo.RootNamespace , upsertQuery)
301271// Handle error
302- fmt.Printf (" %s \n " , resp.QueryResult )
303- fmt.Printf (" %+v \n " , resp.BlankUids )
272+ fmt.Printf (" %s \n " , resp.Json )
273+ fmt.Printf (" %+v \n " , resp.Uids )
304274```
305275
306276### Running a Conditional Upsert
@@ -319,35 +289,24 @@ upsertQuery := `upsert {
319289}`
320290resp , err := client.RunDQL (context.TODO (), dgo.RootNamespace , upsertQuery)
321291// Handle error
322- fmt.Printf (" %s \n " , resp.QueryResult )
292+ fmt.Printf (" %s \n " , resp.Json )
323293```
324294
325295### Creating a New Namespace
326296
327- Dgraph v25 supports namespaces that have names . You can create one using the dgo client.
297+ Dgraph v25 supports creating namespaces using grpc API . You can create one using the dgo client.
328298
329299``` go
330- err := client.CreateNamespace (context.TODO (), " finance-graph " )
300+ _ , err := client.CreateNamespace (context.TODO ())
331301// Handle error
332302```
333303
334- You can now pass this name to ` SetSchema ` , ` RunDQL ` or similar functions.
335-
336304### Dropping a Namespace
337305
338306To drop a namespace:
339307
340308``` go
341- err := client.DropNamespace (context.TODO (), " finance-graph" )
342- // Handle error
343- ```
344-
345- ### Rename a Namespace
346-
347- A namespace can be renamed as follows.
348-
349- ``` go
350- err := client.RenameNamespace (context.TODO (), " finance-graph" , " new-finance-graph" )
309+ _ , err := client.DropNamespace (context.TODO ())
351310// Handle error
352311```
353312
@@ -359,7 +318,7 @@ namespaces, err := client.ListNamespaces(context.TODO())
359318fmt.Printf (" %+v \n " , namespaces)
360319```
361320
362- ## v1 APIs
321+ ## Existing APIs
363322
364323### Creating a Client
365324
@@ -517,8 +476,8 @@ q := `query all($a: string) {
517476 }
518477 }`
519478
520- res , err := txn.QueryWithVars (ctx, q, map [string ]string {" $a" : " Alice" })
521- fmt.Printf (" %s \n " , res .Json )
479+ resp , err := txn.QueryWithVars (ctx, q, map [string ]string {" $a" : " Alice" })
480+ fmt.Printf (" %s \n " , resp .Json )
522481```
523482
524483You can also use ` txn.Do ` function to run a query.
@@ -528,9 +487,9 @@ req := &api.Request{
528487 Query : q,
529488 Vars : map [string ]string {" $a" : " Alice" },
530489}
531- res , err := txn.Do (ctx, req)
490+ resp , err := txn.Do (ctx, req)
532491// Check error
533- fmt.Printf (" %s \n " , res .Json )
492+ fmt.Printf (" %s \n " , resp .Json )
534493```
535494
536495When running a schema query for predicate ` name ` , the schema response is found in the ` Json ` field
@@ -548,9 +507,9 @@ q := `schema(pred: [name]) {
548507 lang
549508}`
550509
551- res , err := txn.Query (ctx, q)
510+ resp , err := txn.Query (ctx, q)
552511// Check error
553- fmt.Printf (" %s \n " , res .Json )
512+ fmt.Printf (" %s \n " , resp .Json )
554513```
555514
556515### Query with RDF response
@@ -570,12 +529,12 @@ const q = `
570529 }
571530}
572531`
573- res , err := txn.QueryRDF (context.Background (), q)
532+ resp , err := txn.QueryRDF (context.Background (), q)
574533// check error
575534
576535// <0x17> <name> "Alice" .
577536// <0x17> <balance> 100 .
578- fmt.Println (res .Rdf )
537+ fmt.Println (resp .Rdf )
579538```
580539
581540` txn.QueryRDFWithVars ` is also available when you need to pass values for variables used in the
0 commit comments