Query Endpoints

Query Properties
Autogenerated Queries
Creating a Query
Editing a Query
Deleting a Query

Queries are endpoints that simply fetches data from one or more of your services. They don't usually modify any data and are simply used for reading data based on a subset of filters or parameters. There are some predefined queries 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 queries to read and filter data in a variety of custom dimensions and logic.

Example: A getMovie query would take in the id of the movie and return the data associated with it.


Query 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

Autogenerated Queries

Certain queries are automatically generated when you publish your graph.


    GraphQL: items({ filter: Filter })
    REST: GET /items

    Fetches all the entries in the table that match the filters provided. Linked tables and their data are autopopulated.


    GraphQL: item({ _id: ID })
    REST: GET /items/:_id (_id is the id of the entry to be fetched)

    Fetches a single entry in the table matching the id provided. Linked tables and their data are autopopulated.

Creating a Query

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


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

Editing a Query

You can edit a query by clicking on the query 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 Query

A query can be deleted by simply right clicking on the query 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. →