Skip to content

Commit

Permalink
feat: lift content type naming restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
axe312ger committed Jun 11, 2021
1 parent 99c46f8 commit 2588df1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 31 deletions.
26 changes: 0 additions & 26 deletions packages/gatsby-source-contentful/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ const { downloadContentfulAssets } = require(`./download-contentful-assets`)

const conflictFieldPrefix = `contentful`

const restrictedContentTypes = [`entity`, `reference`]

exports.setFieldsOnGraphQLNodeType = require(`./extend-node-type`).extendNodeType

const validateContentfulAccess = async pluginOptions => {
Expand Down Expand Up @@ -306,30 +304,6 @@ exports.sourceNodes = async (
}
}

// Check for restricted content type names
const useNameForId = pluginConfig.get(`useNameForId`)

contentTypeItems.forEach(contentTypeItem => {
// Establish identifier for content type
// Use `name` if specified, otherwise, use internal id (usually a natural-language constant,
// but sometimes a base62 uuid generated by Contentful, hence the option)
let contentTypeItemId
if (useNameForId) {
contentTypeItemId = contentTypeItem.name.toLowerCase()
} else {
contentTypeItemId = contentTypeItem.sys.id.toLowerCase()
}

if (restrictedContentTypes.includes(contentTypeItemId)) {
reporter.panic({
id: CODES.FetchContentTypes,
context: {
sourceMessage: `Restricted ContentType name found. The name "${contentTypeItemId}" is not allowed.`,
},
})
}
})

const allLocales = locales
locales = locales.filter(pluginConfig.get(`localeFilter`))
reporter.verbose(
Expand Down
5 changes: 0 additions & 5 deletions packages/gatsby-source-contentful/src/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,4 @@ export const ERROR_MAP = {
level: `ERROR`,
category: `THIRD_PARTY`,
},
[CODES.FetchContentTypes]: {
text: context => context.sourceMessage,
level: `ERROR`,
category: `THIRD_PARTY`,
},
}

0 comments on commit 2588df1

Please sign in to comment.