Overview
GraphQL mutations allow you to create, update, and delete data in your Supabase database. All mutations respect Row Level Security policies.Insert Data
Insert Single Row
Insert a single row into a table:Response
array
Array of inserted records.
Insert Multiple Rows
Insert multiple rows at once:integer
Number of rows inserted.
Insert with Variables
Use variables for dynamic inserts:Update Data
Update Rows
Update rows matching a filter:object
required
Filter to select rows to update.
object
required
Fields to update with new values.
Update Multiple Fields
Update with Variables
Update Multiple Rows
Delete Data
Delete Rows
Delete rows matching a filter:object
required
Filter to select rows to delete.
Delete with Variables
Delete Multiple Rows
Upsert Data
Insert or update based on conflict:object
Conflict resolution strategy.
Batching Mutations
Execute multiple mutations in a single request:Relationships
Insert with Related Data
Insert a country with cities:Error Handling
Validation Errors
Handle validation errors in the response:Constraint Violations
Transactions
All mutations in a single GraphQL request are executed in a transaction:If any mutation in the request fails, all mutations are rolled back.
Optimistic Updates
Return updated data immediately:Row Level Security
Mutations respect RLS policies:Best Practices
Always use filters for updates/deletes
Always use filters for updates/deletes
Prevent accidental bulk operations by always including specific filters:
Use variables for dynamic values
Use variables for dynamic values
Never interpolate values into mutation strings - use variables:
Request updated data
Request updated data
Always request the updated fields to confirm changes:
Handle errors gracefully
Handle errors gracefully
Check for errors in the response and handle them appropriately.
Next Steps
Queries
Learn about querying data
Client Libraries
Use GraphQL with client SDKs
