Modifying field breaks update?

default discord avatar
3 months ago

I am currently trying to move an existing upload field to a custom group field that connects to an external service for file-hosting. This however seems to break our seeding script when existing data is present (which is kinda bad if some data is already present in a staging environment that you want to update).

The field previously was

{name: 'media', type: 'upload', relationTo: 'media', required: true}

and now is

{name: 'media', type: 'group', interfaceName: 'MyCustomMedia', fields: [/* a lot of stuff */]}

Our seeder attempts to update existing values using

await payload.update({id, data: {/* here be data including a media object */}});

However in an


hook on one of the new fields, it turns out the value of the media field is still a string instead of an object.

What am I missing here to fix my update?

Actually... Ignore this for a minute, we might be doing something stupid 🤔



hook is also called


updating which blew up our new field's resolvers. Handling that specific case fixes the seeder!

    Open the post
    Continue the discussion in Discord
    Like what we're doing?
    Star us on GitHub!


    Connect with the Payload Community on Discord



    Can't find what you're looking for?

    Get help straight from the Payload team with an Enterprise License.