0
0
GraphQLquery~20 mins

Transaction handling in GraphQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Transaction Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the result of this transaction sequence?

Consider a GraphQL API that supports transactions with the following operations:

mutation {
  startTransaction {
    transactionId
  }
}

mutation {
  updateUser(id: 1, name: "Alice") {
    id
    name
  }
}

mutation {
  commitTransaction(transactionId: "tx123") {
    success
  }
}

Assuming the updateUser mutation is executed within the transaction started, what will be the final name of the user with id 1 after commit?

AThe user's name will be updated to "Alice" after commit.
BThe user's name will remain unchanged because commitTransaction does not apply changes.
CThe user's name will be "Alice" immediately after updateUser, even before commit.
DThe transaction will fail and the user's name will be rolled back to the previous value.
Attempts:
2 left
💡 Hint

Think about what commitTransaction does in a transaction context.

📝 Syntax
intermediate
1:30remaining
Identify the syntax error in this transaction mutation

Which of the following GraphQL mutations correctly starts a transaction?

Amutation { startTransaction: transactionId }
Bmutation startTransaction { transactionId }
Cmutation { startTransaction(transactionId) }
Dmutation { startTransaction { transactionId } }
Attempts:
2 left
💡 Hint

Recall the correct syntax for GraphQL mutations and field selection.

optimization
advanced
2:30remaining
Optimize transaction usage for multiple updates

You want to update multiple user records atomically using GraphQL transactions. Which approach is best to minimize transaction overhead?

AStart a transaction, update each user one by one inside it, then commit once at the end.
BStart and commit a separate transaction for each user update.
CUpdate all users without transactions to improve speed.
DStart a transaction, update one user, commit, then start a new transaction for the next user.
Attempts:
2 left
💡 Hint

Think about how transactions reduce overhead when grouping operations.

🔧 Debug
advanced
2:00remaining
Why does this transaction rollback unexpectedly?

Given this sequence:

mutation { startTransaction { transactionId } }
mutation { updateUser(id: 2, name: "Bob") { id name } }
mutation { rollbackTransaction(transactionId: "tx999") { success } }

The updateUser mutation is executed, but the rollbackTransaction uses a wrong transactionId. What happens to the update?

AThe updateUser mutation fails because the transaction is invalid.
BThe updateUser change is rolled back despite the wrong transactionId.
CThe updateUser change remains uncommitted and visible only inside the transaction.
DThe updateUser change is committed automatically because rollback failed.
Attempts:
2 left
💡 Hint

Consider what happens if rollbackTransaction targets a non-existent transaction.

🧠 Conceptual
expert
3:00remaining
What is the isolation level effect in GraphQL transactions?

In a GraphQL API supporting transactions, what does the isolation level control?

AThe order in which mutations are executed inside a transaction.
BHow visible uncommitted changes are to other transactions.
CThe maximum time a transaction can stay open before auto-commit.
DThe number of concurrent transactions allowed per user.
Attempts:
2 left
💡 Hint

Think about what isolation means in database transactions.