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.
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 calledmovies
, the query name would beallMovie
You can read more on how to write more advanced queries here