-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
area: docsImprovements or additions to documentationImprovements or additions to documentationcreated-by: Payload team
Description
Documentation Issue
There are a lack of examples in the docs using strongly-typed Access Control and Hooks.
Additional Details
For example:
After Change Hook
Current Docs:
import type { CollectionAfterChangeHook } from 'payload'
const afterChangeHook: CollectionAfterChangeHook = async ({ doc }) => {
return doc
}
Strongly-typed using generated types:
import type { CollectionAfterChangeHook } from 'payload'
import type { Config, Page } from '../../../payload-types'
export const revalidatePage: CollectionAfterChangeHook<Page> = ({
doc,
previousDoc,
req: { payload, locale },
}) => {
// doc and previous doc are now fully typed
return doc
}
Access Control
Current Docs
const access = ({ req }) => {
// Grant access if the locale is 'en'
if (req.locale === 'en') {
return true
}
// Deny access for all other locales
return false
}
Updated docs should use Access<T>
generic
bratvanov
Metadata
Metadata
Assignees
Labels
area: docsImprovements or additions to documentationImprovements or additions to documentationcreated-by: Payload team