diff --git a/gatsby-source-graphcms/README.md b/gatsby-source-graphcms/README.md index 837286d..187e49a 100644 --- a/gatsby-source-graphcms/README.md +++ b/gatsby-source-graphcms/README.md @@ -61,6 +61,12 @@ module.exports = { - If your GraphCMS project is **not** publicly accessible, you will need to provide a [Permanent Auth Token](https://graphcms.com/docs/reference/authorization) to correctly authorize with the API. You can learn more about creating and managing API tokens [here](https://graphcms.com/docs/guides/concepts/apis#working-with-apis). +- `typePrefix` _String_ (default value: `GraphCMS_`) + + > If using multiple instances of the source plugin, you **must** provide a value here to prevent type conflicts. + + - The string by which every generated type name is prefixed with. For example, a type of `Post` in GraphCMS would become `GraphCMS_Post` by default. + - `downloadLocalImages` _Boolean_ (default value: `false`) - Download and cache GraphCMS image assets in your Gatsby project. [Learn more](#downloading-local-image-assets). @@ -71,6 +77,8 @@ module.exports = { - `fragmentsPath` _String_ (default value: `graphcms-fragments`) + > If using multiple instances of the source plugin, you **must** provide a value here to prevent type and/or fragment conflicts. + - The local project path where generated query fragments are saved. This is relative to your current working directory. - `locales` _[String]_ (default value: `['en']`) diff --git a/gatsby-source-graphcms/gatsby-node.js b/gatsby-source-graphcms/gatsby-node.js index 4914462..f36ee31 100644 --- a/gatsby-source-graphcms/gatsby-node.js +++ b/gatsby-source-graphcms/gatsby-node.js @@ -34,7 +34,13 @@ exports.onPreBootstrap = ({ reporter }, pluginOptions) => { const createSourcingConfig = async ( gatsbyApi, - { endpoint, fragmentsPath = 'graphcms-fragments', locales = ['en'], token } + { + endpoint, + fragmentsPath = 'graphcms-fragments', + locales = ['en'], + token, + typePrefix = 'GraphCMS_', + } ) => { const execute = async ({ operationName, query, variables = {} }) => { return await fetch(endpoint, { @@ -122,7 +128,7 @@ const createSourcingConfig = async ( gatsbyApi, schema, execute: wrapQueryExecutorWithQueue(execute, { concurrency: 10 }), - gatsbyTypePrefix: `GraphCMS_`, + gatsbyTypePrefix: typePrefix, gatsbyNodeDefs: buildNodeDefinitions({ gatsbyNodeTypes, documents }), } }