Description:
Currently, when a document has not been published, the translation does not take place because findEntityWithConfig only queries payload documents that are published. This occurs because the default behavior of the find query is draft: false.
Steps to Reproduce:
- Attempt to retrieve a draft (unpublished) document using
findEntityWithConfig.
- Observe that the document is not found, leading to missing translations.
Proposed Fix:
To allow translations to work for draft documents, add the draft: true property in the payload queries.
Current Code (Problematic)
const docPromise = isGlobal
? payload.findGlobal({
depth: 0,
fallbackLocale: undefined,
locale: locale as any,
overrideAccess,
req,
slug: args.globalSlug as GlobalSlug,
})
: payload.findByID({
collection: collectionSlug as CollectionSlug,
depth: 0,
fallbackLocale: undefined,
id: id as number | string,
locale: locale as any,
overrideAccess,
req,
});
Updated Code (Fix)
const docPromise = isGlobal
? payload.findGlobal({
depth: 0,
fallbackLocale: undefined,
locale: locale as any,
overrideAccess,
req,
slug: args.globalSlug as GlobalSlug,
draft: true, // Allow retrieval of draft documents
})
: payload.findByID({
collection: collectionSlug as CollectionSlug,
depth: 0,
fallbackLocale: undefined,
id: id as number | string,
locale: locale as any,
overrideAccess,
req,
draft: true, // Allow retrieval of draft documents
});
Expected Behavior:
- Draft (unpublished) documents should be retrievable by
findEntityWithConfig, ensuring translations occur correctly.
Environment:
- Payload Version: 3.23.0
- Node.js Version: 20.x.x
- Database: postgressSql
Additional Context:
This fix ensures that draft documents are accessible in the translation workflow, preventing issues where unpublished documents fail to be retrieved.
Description:
Currently, when a document has not been published, the translation does not take place because
findEntityWithConfigonly queries payload documents that are published. This occurs because the default behavior of thefindquery isdraft: false.Steps to Reproduce:
findEntityWithConfig.Proposed Fix:
To allow translations to work for draft documents, add the
draft: trueproperty in the payload queries.Current Code (Problematic)
Updated Code (Fix)
Expected Behavior:
findEntityWithConfig, ensuring translations occur correctly.Environment:
Additional Context:
This fix ensures that draft documents are accessible in the translation workflow, preventing issues where unpublished documents fail to be retrieved.