From b9868c4a3be313f7e30247e899fc5a7ab7f4adf0 Mon Sep 17 00:00:00 2001 From: Samuel Gabriel <144083942+sam-gab@users.noreply.github.com> Date: Fri, 2 May 2025 01:58:51 +0800 Subject: [PATCH] fix: allow custom admin user collection in query presets constraints (#12202) Query preset "Specific User" constraints is currently fixed to `users` collection. However, this will fail if one has a custom admin user collection. --- packages/payload/src/query-presets/constraints.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/payload/src/query-presets/constraints.ts b/packages/payload/src/query-presets/constraints.ts index 8e9cec4f5..33603d2f1 100644 --- a/packages/payload/src/query-presets/constraints.ts +++ b/packages/payload/src/query-presets/constraints.ts @@ -74,7 +74,7 @@ export const getConstraints = (config: Config): Field => ({ }, ], }, - relationTo: 'users', + relationTo: config.admin?.user ?? 'users', // TODO: remove this fallback when the args are properly typed as `SanitizedConfig` }, ...(config?.queryPresets?.constraints?.[operation]?.reduce( (acc: Field[], option: QueryPresetConstraint) => {