Mutation Endpoints

Mutation Properties
Autogenerated Mutations
Creating a Mutation
Editing a Mutation
Deleting a Mutation

Mutations are endpoints that mutate or change the content on the backend. There are some predefined mutations that are automatically generated by Canonic whenever you publish your graph.

You can modify these endpoints to augment them with your own business logic, or, alternatively create brand new endpoints to infinitely extend your backend to be incredibly complex and powerful.

Example: A createMovie mutation would take in movie parameters and create a movie with those parameters.


Mutation Properties

Property Description
Key The identifier for the api. It's also used as the operation name in the Graphql api. Must be unique.
Path The rest api endpoint path. This is the url through which the endpoint will be triggered.
Method The http method for the rest api. Ideally should represent the type of operation being performed.
Output Type Whether the endpoint will return a list of items or a single object. Endpoints must return the same type as the parent table they're created under. Ex. a movies endpoint must return either a list of movies or a single movie.
Input A JSON representation defining the input for the endpoint. The keys represent the input parameters and their values represent their respective types. Read More
Code The code for the endpoint. Currently we only support Javascript (Node). Define a module export and add your business logic to the function.
It can be executed by both REST & GraphQL APIs. It's called with all the paramaters specified in the input. The data returned from the function will be returned to the user. Read More
Description A description for the API summarizing it's intent. It's used in the generated documentation for helpful direction when using the endpoint
Wait for webhooks If webhooks are added, you can wait for the webhooks to complete before returning. The webhook data is returned inside the extensions field when turned on.

Autogenerated Mutations

Certain mutations are automatically generated when you publish your graph.


    GraphQL: createItem({ input: ItemInput })
    REST: POST /items

    Allows you to create an entry for the table corresponding to the graph. It takes the fields defined in the graph as input paramters. Returns the created document on success.


    GraphQL: updateItem({ _id: ID, input: ItemInput })
    REST: PATCH /items/:_id (_id is the id of the entry to be updated)

    Allows you to update an existing entry in the table. Only the keys that need to be updated need to be provided. Returns the updated document on success.


    GraphQL: deleteItem({ _id: ID })
    REST: DELETE /items/:_id (_id is the id of the entry to be deleted)

    Allows you to delete an existing entry in the table. The _id provided in the url parameter would be used to delete the record. Returns the deleted document on success.

    This is a permanent action. Be careful while executing this mutation.

Creating a Mutation

Create a mutation by clicking on the + NEW MUTATION button below all the existing mutations. You will see a new mutation pop up on the graph with the the properties panel for the mutation visible on the right side. Fill out the properties. Once done, close the properties panel to save your changes.

New mutations won't be available in already live APIs unless published. See [Publishing] for more information.

Editing a Mutation

You can edit a mutation by clicking on the mutation node on the graph. The properties panel will open up where you can edit all necessary properties.


Note: Some properties are editable but are not recommended to be edited once you go live with your project as they can cause loss of data. You will be shown a warning when performing such actions.

Note Although changes are saved automatically, they must be published for them to reflect in the Docs and be available for consumption.

Deleting a Mutation

A mutation can be deleted by simply right clicking on the mutation and selecting delete.


Caution! This is a dangerous action and can cause permanent loss of data once the graph is published.

Did you find what you were looking for?
What went wrong?
Need more help?We have a thriving Discordcommunity that can help you with all things Canonic. →