Skip to content

Commit c3fc6da

Browse files
committed
feat: throw error on reservated field names
1 parent 5740e22 commit c3fc6da

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/gatsby-source-contentful/src/create-schema-customization.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,13 @@ export async function createSchemaCustomization(
527527
if (field.disabled || field.omitted) {
528528
return
529529
}
530+
if ([`id`, `sys`, `contentfulMetadata`].includes(field.id)) {
531+
// Throw error on reserved field names as the Contenful GraphQL API does:
532+
// https://www.contentful.com/developers/docs/references/graphql/#/reference/schema-generation/fields
533+
throw new Error(
534+
`Unfortunately the field name ${field.id} is reserved. ${contentTypeItem.name}@${contentTypeItem.sys.id}`
535+
)
536+
}
530537
fields[field.id] = translateFieldType(field, schema, createTypes)
531538
})
532539

0 commit comments

Comments
 (0)