Skip to content

Commit 760cfad

Browse files
authored
fix: do not append doc input for scheduled publish job if it's enabled only for globals (#11892)
Fixes #11891 Previously, if you had scheduled publish enabled only for globals, not collections - you'd get an error on `payload generate:types`: <img width="886" alt="image" src="https://github.com/user-attachments/assets/78125ce8-bd89-4269-bc56-966d8e0c3968" /> This was caused by appending the `doc` field to the scheduled publish job input schema with empty `collections` array. Now we skip this field if we don't have any collections.
1 parent d29bdfc commit 760cfad

File tree

1 file changed

+10
-5
lines changed
  • packages/payload/src/versions/schedule

1 file changed

+10
-5
lines changed

packages/payload/src/versions/schedule/job.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// @ts-strict-ignore
22
import type { User } from '../../auth/types.js'
3+
import type { Field } from '../../fields/config/types.js'
34
import type { TaskConfig } from '../../queues/config/types/taskTypes.js'
45
import type { SchedulePublishTaskInput } from './types.js'
56

@@ -87,11 +88,15 @@ export const getSchedulePublishTask = ({
8788
name: 'locale',
8889
type: 'text',
8990
},
90-
{
91-
name: 'doc',
92-
type: 'relationship',
93-
relationTo: collections,
94-
},
91+
...(collections.length > 0
92+
? [
93+
{
94+
name: 'doc',
95+
type: 'relationship',
96+
relationTo: collections,
97+
} satisfies Field,
98+
]
99+
: []),
95100
{
96101
name: 'global',
97102
type: 'select',

0 commit comments

Comments
 (0)