Issue with alternate alternate_languages field

Hi,

I create a document in english language using the migration API. It gets created. I create german document using migration api and alternate_language_id is of the english document. I can see the relation on the prismic UI.
But, when i check the relation using the get document api, i am unable to get the german alternate_languages for english document. I have to publish the document. I think, regardless of the document is published or not, the relation should be shown. This feature is useful to track the relation and get other language documents.

Hi @rpalresha ,

This is an interesting idea but hard to implement because 'draft' documents are unknown to the content API. The migration API only exports published documents as seen in the content API.

I've passed the idea to the team so they can consider this, but in the meantime do you have any ideas/preferences on how this might work?

Thanks.

The content API will not shows the alternate language id if the other language document is published. If the other language document is not published, then it will not be shown. I think, if the document is added to release or in edit stage then the API should know that there exist a document in other locale. And the same document id should be shown in the content API, alternate language id.

It's an interesting idea, but the issue then becomes on your live website; if you have a published document with a link to another alternative language, then the link will exist, but the document will not. So if your user clicks the 'switch language' button they'll get a broken URL.

Have you tried querying all your documents from the Content API using the release ref where you added the draft document? This would maintain the alternate language.

You can find the release refs in your cdn endpoint e.g.
https://your-repo-name.cdn.prismic.io/api/v2