diff --git a/wiki/content/mutations/index.md b/wiki/content/mutations/index.md index bf661c3e546..e9160799b90 100644 --- a/wiki/content/mutations/index.md +++ b/wiki/content/mutations/index.md @@ -779,6 +779,58 @@ Mutation with a JSON file: curl -H "Content-Type: application/json" -X POST localhost:8080/mutate?commitNow=true -d @data.json ``` +where the contents of data.json looks like the following: + +```json +{ + "set": [ + { + "name": "Alice" + }, + { + "name": "Bob" + } + ] +} +``` + +The JSON file must follow the same format for mutations over HTTP: a single JSON +object with the `"set"` or `"delete"` key and an array of JSON objects for the +mutation. If you already have a file with an array of data, you can use `jq` to +transform your data to the proper format. For example, if your data.json file +looks like this: + +```json +[ + { + "name": "Alice" + }, + { + "name": "Bob" + } +] +``` + +then you can transform your data to the proper format with the following `jq` +command, where the `.` in the `jq` string represents the contents of data.json: + +```sh +cat data.json | jq '{set: .}' +``` + +``` +{ + "set": [ + { + "name": "Alice" + }, + { + "name": "Bob" + } + ] +} +``` + ## Upsert Block The Upsert block allows performing queries and mutations in a single request. The Upsert