Mutations
EdgeDB provides GraphQL mutations to perform delete
, insert
and update
operations.
Delete
The “delete” mutation is very similar in structure to a query. Basically, it works the same way as a query, using the filter, order, and various pagination parameters to define a set of objects to be deleted. These objects are also returned as the result of the delete mutation. Each object type has a corresponding delete_
mutation:
GraphQL | EdgeQL equivalent |
---|---|
Copy
| Copy
|
Copy
| Copy
|
Copy
| Copy
|
Insert
The “insert” mutation exists for every object type. It allows creating new objects and supports nested insertions, too. The objects to be inserted are specified via the data
parameter, which takes a list of specifications. Each such specification has the same structure as the object being inserted with required and optional fields (although if a field is required in the object, but has a default it’s optional in the insert specification):
GraphQL | EdgeQL equivalent |
---|---|
Copy
| Copy
|
It’s possible to insert a nested structure all at once (e.g. a new book and a new author):
GraphQL | EdgeQL equivalent |
---|---|
Copy
| Copy
|
It’s also possible to insert a new object that’s connected to an existing object (e.g. a new book by an existing author). In this case the nested object is specified using filter, order, and various pagination parameters to define a set of objects to be connected:
GraphQL | EdgeQL equivalent |
---|---|
Copy
| Copy
|
Update
The “update” mutation has features that are similar to both an “insert” mutation and a query. On one hand, the mutation takes filter, order, and various pagination parameters to define a set of objects to be updated. On the other hand, the data
parameter is used to specify what and how should be updated.
The data
parameter contains the fields that should be altered as well as what type of update operation must be performed (set
, increment
, append
, etc.). The particular operations available depend on the type of field being updated.
GraphQL | EdgeQL equivalent |
---|---|
Copy
| Copy
|