Migrate to Netlify Today

Netlify announces the next evolution of Gatsby Cloud. Learn more

ContactSign Up
Community Plugin
View plugin on GitHub

Canonic Gatsby Source Plugin

A Gatsby source plugin to pull data from Canonic APIs. Once installed, your API can be queried from within Gatsby using GraphQL.

Release npm version

Install

yarn add gatsby-source-canonic

Configureation

After installing the plugin, use and configure the plugin by modifying your site’s gatsby-config.js.

// gatsby.config.js

module.exports = {
  plugins: [
    //...other plugins
    {
      resolve: 'gatsby-source-canonic',
      options: {
        url: "YOUR_API_URL",
        apiKey: process.env.CANONIC_ACCESS_TOKEN
      }
    }
  ]
}

It’s recommended to use dotenv to configure env variables and store the token there.

You can create an access token by visiting the settings page of your Canonic project. Read More

Usage

Once the plugin is configured, you can query for Canonic data as you would from any other source

{
  allTABLE_NAME {
    edges {
      node {
        _id
        ...
      }
    }
  }
}

TABLE_NAME is the key for the table corresponding to Canonic. So if you created a table called movies, the query name would be allMovie

You can read more on how to write more advanced queries here

© 2024 Gatsby, Inc.