Describe your question/issue in detail
Hi,
I'm working on a tool to automate migrations in Prismic. Everything is working about 95%, but I'm running into one issue regarding fetching content that lives inside a migration release (not master).
Here’s the step-by-step breakdown of what works so far:
What works:
- Creating first-level pages (custom page type) → Works perfectly
- Creating second-level pages (linked to the first-level ones) → Also works fine
So at this point, I've created:
- A document of type Sector
- A document of type Article
These are now sitting in the Migration release (not published yet).
The problem:
When the migration script continues and detects that the Sector already exists (great!), it should then:
- Pull that document from the migration release (not from master)
- Extract the id and data
- Proceed to link or extend from that content
But I can't seem to fetch content from the Migration release — it always returns content from the published documents (master), even though I'm passing the correct ref.
What I’ve tried:
- I get the release ref:
const allReleases = await client.getReleases(); // Gets correct migration release ref
const masterRef = await client.getMasterRef(); // Confirmed not using this
- I try to tell the client to use the release ref:
client.queryContentFromRef("the-migration-ref");
// No effect
- I try to force the ref when creating the client:
const client = prismic.createClient("https://my-repo.cdn.prismic.io/api/v2", {
accessToken: "my-access-token-with-permissions",
ref: "the-migration-ref",
});
// Still, it only fetches published documents.
- I try using writeClient with the write API token:
const writeClient = createWriteClient(“my-repo", {
writeToken: "my-write-token",
accessToken: "my-access-token",
});
// Same issue — I can create just fine, but when trying to getByUID() or getAllByType(...), I still get only master documents.
The question:
How can I force my client (or any method) to fetch from a specific release ref (i.e., the Migration release), so that I can access documents that exist only there?
I’m explicitly passing the ref in the query but getting back content only from the master. Is there something special about querying unpublished content in a release that I’m missing?
Thanks in advance!