gatsby-source-morty
v0.3.3
Published
Gatsby source plugin for building websites using the Morty CMS as a data source
Downloads
2
Readme
Gatsby MortyCMS Source
A gatsby plugin that runs a graphql query and parses it's response based on a schema to get your data properly into gatsby's world.
Usage
Add the following with your settings to the gatsby-config.js file under plugins:
{
resolve: `gatsby-source-morty`,
options: {
account: `awesome-co`,
accessToken: `00000000-0000-0000-0000-000000000000`
}
},
For development, you can just add gatsby-source-morty
to plugins and it will point to localhost:3000/graphql
.
Process / Workflow
- Download and cache the schema from the server (
utils/getSchema
) - Build client scheme from that schema
- Parse the client query to query AST and operation AST
- Gather fragment definitions
- Validate the query is valid for the schema
- Run query against server
- Use the type info of the schema to walk through the operations
- Recursively make nodes from the data, using fragments as needed