Hey Team,
We are currently in the middle of performing our first migration and have updated one of our models with some new fields via the contentful-migration library.
The migration of the new fields is done like so:
const gameInfo = migration.editContentType(‘gameInfo’);
gameInfo
.createField(‘imgUrlPattern’)
.name(‘imgUrlPattern’)
.type(‘Symbol’);
gameInfo.changeFieldControl(‘imgUrlPattern’, ‘builtin’, ‘singleLine’, {
helpText: ‘todo’
});
This works fine and we see the new fields appear in the web app.
However, when trying to update entries and put some values into these new fields via the contentful-management library (following the docs here Content Management API | Contentful), we found that they were not being returned in the getEntry response:
await environment
.getEntry(entryID)
.then((entry) => {
entry.fields.imgUrlPattern[‘en-GB’] = ‘/test.jpg’;
return entry.update();
});
The problem here is that entry.fields only contains existing fields, and none of the new ones created during the migration are present. This code updates existing fields just fine and also works on the new fields if we manually put a value in there via the web app first.
I guess the question I’m asking is:
Is it expected behaviour for fields that have been created, but never had a value put into them (manually or programmatically at creation) to not be returned by get queries from the contentful-management library?
Cheers