github payloadcms/payload v3.0.0-beta.15

latest releases: v3.0.0-beta.56, v2.23.1, payload/2.23.1...
pre-release2 months ago

What's Changed

Features

  • feat!: removed getDataAndFile and getLocales from createPayloadRequest in favour of new utilities addDataAndFileToRequest and addLocalesToRequest by @paulpopus in #5999
  • feat(richtext-lexical)!: rework population behavior and allow richText adapter field hooks by @AlessioGr in #5893

Fixes

⚠ BREAKING CHANGES

  • feat!: removed getDataAndFile and getLocales from createPayloadRequest in favour of new utilities addDataAndFileToRequest and addLocalesToRequest by @paulpopus in #5999

Custom handlers will no longer resolve data, locale and fallbackLocale for you. Instead you can use our provided utilities from the next package

// ❌ Before
{
  path: '/whoami/:parameter',
  method: 'post',
  handler: async (req) => {
    return Response.json({
      name: req.data.name, // data will be undefined
      // locales will be undefined
      fallbackLocale: req.fallbackLocale,
      locale: req.locale,
    })
  }
} 

// ✅ After
import { addDataAndFileToRequest } from '@payloadcms/next/utilities'
import { addLocalesToRequest } from '@payloadcms/next/utilities'

{
  path: '/whoami/:parameter',
  method: 'post',
  handler: async (req) => {
    // mutates req, must be awaited
    await addDataAndFileToRequest(req)
    
    // mutates req
    addLocalesToRequest(req)
	  
    return Response.json({
      name: req.data.name, // data is now available
      fallbackLocale: req.fallbackLocale, // locales available
      locale: req.locale,
    })
  }
} 

Full Changelog: v3.0.0-beta.14...v3.0.0-beta.15

Don't miss a new payload release

NewReleases is sending notifications on new releases.