Skip to content

Commit

Permalink
feat: throw error on reservated field names
Browse files Browse the repository at this point in the history
  • Loading branch information
axe312ger committed May 17, 2022
1 parent 37f652d commit 8aa8f20
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,13 @@ export async function createSchemaCustomization(
if (field.disabled || field.omitted) {
return
}
if ([`id`, `sys`, `contentfulMetadata`].includes(field.id)) {
// Throw error on reserved field names as the Contenful GraphQL API does:
// https://www.contentful.com/developers/docs/references/graphql/#/reference/schema-generation/fields
throw new Error(
`Unfortunately the field name ${field.id} is reserved. ${contentTypeItem.name}@${contentTypeItem.sys.id}`
)
}
fields[field.id] = translateFieldType(field, schema, createTypes)
})

Expand Down

0 comments on commit 8aa8f20

Please sign in to comment.