From d6d9edc304ad92ecba70be3ff369a7df848b96e6 Mon Sep 17 00:00:00 2001 From: "Angel P." Date: Thu, 2 Jan 2025 18:08:07 -0500 Subject: [PATCH] docs: warn when using `defaultPopulate` on collections with uploads enabled (#10138) When `defaultPopulate` is enabled without specifying `filename: true` and `url: true` for collections with an upload field. The upload will not have a valid URL when returned from Payload APIs and will instead be returned with a value of `null` --------- Co-authored-by: Sasha <64744993+r1tsuu@users.noreply.github.com> --- docs/queries/select.mdx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/queries/select.mdx b/docs/queries/select.mdx index b38def1427..36d7bc560b 100644 --- a/docs/queries/select.mdx +++ b/docs/queries/select.mdx @@ -137,6 +137,11 @@ export const Pages: CollectionConfig<'pages'> = { } ``` + + Important: + When using `defaultPopulate` on a collection with [Uploads](/docs/fields/upload) enabled and you want to select the `url` field, it is important to specify `filename: true` as well, otherwise Payload will not be able to construct the correct file URL, instead returning `url: null`. + + ## populate Setting `defaultPopulate` will enforce that each time Payload performs a "population" of a related document, only the fields specified will be queried and returned. However, you can override `defaultPopulate` with the `populate` property in the Local and REST API: