Get most deeply nested linked entries using GetEntries() and Include parameter

I’m writing a migration tool to move content from 1 environment to another (using contentful-import, contentful-export). I believe I am having some issues because when I try to migrate entry X, it has linked entries that are not being migrated and published before X is published. Thus, X is attempting to publish with some unresolved links. Is there a way, using CDA and ‘include’ parameter, to get the most deeply nested linked entries, migrate and publish them first, and then recursively move up the “include” tree until finally migrating and publishing X?

A note, I’ve also tried using the CMA with the same results.

Hi @nobbe_derek

I think this answer could help you:

In particular, the approach the other user took is to:

  • Use CMA for the import (for export maybe it could still be used the Contentful-export)
  • First update the entries from one environment to another one
  • Then do a second passage to re-publish all the entries