Dashes (e.g. my-field) in the Prismic field names and migration to gatsby-source-prismic

Hi, I wanted to migrate to the new plugin gatsby-source-prismic, but I encountered an obstacle. All my field names on Prismic contain dashes (e.g. my-field) and that is one of the limitations of this new plugin. Changing the field names is not an option, because that would mean loosing all of the data.. What do you suggest to do in this case?

Hello Ziga,

Welcome to the Prismic community.

It's true that the new gatsby plugin doesn't support the dashes (my-title) in the API ID. It should be either in underscores or one word. If you remove or rename the API ID of a Prismic field, the data returned from the API will be empty. Content won't be migrated from the old field.
Here is the article link that explains the case.

Let me know if you have other doubt.

Thanks,

Priyanka

Hi, thank you for your reply! Problem is the fact that the content won't be migrated from the old field.. Is there any way to migrate the content, because not doing so would create a lot of extra work that will have to be done manually..

Hello, @ztrontelj96,

Sorry for the delayed response. Yes, It's true that if you change the API ID of the field, you lose the data. You can migrate the data from the old field to the new field using the import-export feature.
You can achieve this by:

  • Exporting the JSON files of your Prismic documents by using the Export module.
  • Make a script to copy data from the old field to the new one in the JSON files.
  • Compress and import the modified JSON files.

Note: the Import/Export feature is only available starting from the Medium plan.

Please let me know if you have any other doubt.

Best,

Priyanka

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.