You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -102,8 +109,8 @@ op = pydgraph.Operation(schema=schema, run_in_background=True)
102
109
client.alter(op)
103
110
```
104
111
105
-
`Operation` contains other fields as well, including drop predicate and drop all.
106
-
Drop all is useful if you wish to discard all the data, and start from a clean
112
+
`Operation` contains other fields as well, including the `drop` predicate and `drop all`.
113
+
Drop all is useful if you wish to discard all the data, and start with a clean
107
114
slate, without bringing the instance down.
108
115
109
116
```python
@@ -115,7 +122,7 @@ client.alter(op)
115
122
116
123
### Creating a Transaction
117
124
118
-
To create a transaction, call `DgraphClient#txn()` method, which returns a
125
+
To create a transaction, call the `DgraphClient#txn()` method, which returns a
119
126
new `Txn` object. This operation incurs no network overhead.
120
127
121
128
It is good practice to call `Txn#discard()` in a `finally` block after running
@@ -202,7 +209,7 @@ txn.mutate(del_obj=person)
202
209
```
203
210
204
211
For a complete example with multiple fields and relationships, look at the
205
-
[simple] project in the `examples` folder.
212
+
[simple project][simple] in the `examples` folder.
206
213
207
214
Sometimes, you only want to commit a mutation, without querying anything further.
208
215
In such cases, you can set the keyword argument `commit_now=True` to indicate
@@ -219,7 +226,7 @@ txn.do_request(request)
219
226
### Committing a Transaction
220
227
221
228
A transaction can be committed using the `Txn#commit()` method. If your transaction
222
-
consisted solely of calls to `Txn#query` or `Txn#queryWithVars`, and no calls to
229
+
consist solely of `Txn#query` or `Txn#queryWithVars` calls, and no calls to
223
230
`Txn#mutate`, then calling `Txn#commit()` is not necessary.
224
231
225
232
An error is raised if another transaction(s) modify the same data concurrently that was
@@ -245,11 +252,11 @@ finally:
245
252
### Running a Query
246
253
247
254
You can run a query by calling `Txn#query(string)`. You will need to pass in a
248
-
GraphQL+- query string. If you want to pass an additional dictionary of any
255
+
[DQL](https://dgraph.io/docs/query-language/) query string. If you want to pass an additional dictionary of any
249
256
variables that you might want to set in the query, call
250
257
`Txn#query(string, variables=d)` with the variables dictionary `d`.
251
258
252
-
The response would contain the field `json`, which returns the response JSON.
259
+
The query response contains the `json` field, which returns the JSON response.
253
260
254
261
Let’s run a query with a variable `$a`, deserialize the result from JSON and
255
262
print it out:
@@ -296,8 +303,7 @@ txn.do_request(request)
296
303
The `txn.do_request` function allows you to run upserts consisting of one query and
297
304
one mutation. Query variables could be defined and can then be used in the mutation.
298
305
299
-
To know more about upsert, we highly recommend going through the docs at
300
-
https://docs.dgraph.io/mutations/#upsert-block.
306
+
To know more about upsert, we highly recommend going through the [mutations docs](https://docs.dgraph.io/mutations/#upsert-block).
301
307
302
308
```python
303
309
query ="""{
@@ -317,7 +323,7 @@ txn.do_request(request)
317
323
The upsert block also allows specifying a conditional mutation block using an `@if` directive. The mutation is executed
318
324
only when the specified condition is true. If the condition is false, the mutation is silently ignored.
319
325
320
-
See more about Conditional Upsert [Here](https://docs.dgraph.io/mutations/#conditional-upsert).
326
+
See more about Conditional Upserts [here](https://docs.dgraph.io/mutations/#conditional-upsert).
321
327
322
328
```python
323
329
query ="""
@@ -359,7 +365,9 @@ stub2.close()
359
365
```
360
366
361
367
### Setting Metadata Headers
368
+
362
369
Metadata headers such as authentication tokens can be set through the metadata of gRPC methods. Below is an example of how to set a header named "auth-token".
370
+
363
371
```python
364
372
# The following piece of code shows how one can set metadata with
365
373
# auth-token, to allow Alter operation, if the server requires it.
0 commit comments