Skip to main content

Overview

GraphQL mutations allow you to create, update, and delete data in your Supabase database. All mutations respect Row Level Security policies.
GraphQL mutations are currently in beta. The API is functional but may receive updates.

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:
Variables:

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

Variables:

Update Multiple Rows

Delete Data

Delete Rows

Delete rows matching a filter:
object
required
Filter to select rows to delete.
Always include a filter when deleting to avoid removing all rows.

Delete with Variables

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 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

Prevent accidental bulk operations by always including specific filters:
Never interpolate values into mutation strings - use variables:
Always request the updated fields to confirm changes:
Check for errors in the response and handle them appropriately.

Next Steps

Queries

Learn about querying data

Client Libraries

Use GraphQL with client SDKs