Skip to main content


We can perform transactions in GraphQL by passing a variable to a GraphQL mutation. This variable should contain a JSON-formatted parcel of data without line breaks.

As you can see in the below example, in order to add people, we store the JSON-formatted data in a variable called myPeopleTx and use the variable myPeopleTx in the mutation statement.

We also need to ensure that all " are escaped, like so \".

mutation addPeople ($myPeopleTx: JSON) {
transact(tx: $myPeopleTx)

"myPeopleTx": "[
{ \"_id\": \"person\", \"handle\": \"jdoe\", \"fullName\": \"Jane Doe\" },
{ \"_id\": \"person\", \"handle\": \"zsmith\", \"fullName\": \"Zach Smith\" }]"

For the challenge question, you'll be writing the mutation statement. We've provide the escaped transaction as a variable below:

"artistTx": "[{\"_id\":\"artist$1\",\"name\":\"Michelangelo\"},{\"_id\":\"artist$2\",\"name\":\"Rembrandt\"},{\"_id\":\"artist$3\",\"name\":\"Monet\"}]"

Write a Mutation

Write the mutation statement that would correspond to the above variable, artistTx.

Use the first transaction in this lesson for reference.