TL;DR
PayloadCMS v3.35.0 introduces several powerful new features including virtual relationship fields that can be queried and sorted, a new relationship field drawer UI option, reusable auth server functions, and operation context in field conditions. This release also fixes important bugs related to draft documents, custom endpoints, and UI components while improving performance and documentation.
Highlight of the Release
- Virtual relationship fields that are queryable, sortable, and can be used as titles
- New list drawer UI option for relationship fields with advanced filtering
- Reusable auth server functions for login, logout, and refresh operations
- Operation context now available in field condition functions
- Fixed data loss issue when reordering draft documents
Migration Guide
No breaking changes were introduced in this release, so no migration is required.
If you want to take advantage of the new features:
-
Virtual Relationship Fields: Update your collection configs to use the new virtual property with relationship paths:
{
name: 'postTitle',
type: 'text',
virtual: 'post.title',
}
-
Relationship Field List Drawer: Add the selectionType property to your relationship fields:
{
name: 'author',
type: 'relationship',
relationTo: 'users',
admin: {
selectionType: 'drawer' // Use 'dropdown' for the default behavior
}
}
-
Reusable Auth Server Functions: Import the new functions from @payload/next/server-functions:
import { login, logout, refresh } from '@payload/next/server-functions';
-
Field Condition with Operation: Update your field condition functions to use the new operation parameter:
{
condition: (data, siblingData, { user, operation }) => {
// Use operation to determine context
return operation === 'create' ? true : data.someField === true;
}
}
Upgrade Recommendations
This is a feature-rich release with important bug fixes and no breaking changes. It's recommended to upgrade to v3.35.0 as soon as possible, especially if you:
- Are experiencing issues with draft documents when reordering
- Need better relationship field selection interfaces
- Want to use virtual fields that can be queried and sorted
- Need server-side authentication functions
- Are using custom endpoints and need proper CORS handling
The upgrade process should be straightforward:
npm install [email protected]
# or
yarn add [email protected]
# or
pnpm add [email protected]
After upgrading, test your application thoroughly, especially if you're using features related to the fixed bugs such as draft documents, relationship fields, or custom endpoints.
Bug Fixes
Critical Fixes
- Fixed a data loss issue when reordering draft documents by removing the
select optimization that was causing draft versions to be updated without data
- Ensured CORS headers are properly applied to custom endpoints
- Fixed an issue where boolean query preset constraints were not being respected
UI Improvements
- Fixed stale paths on custom components within rows that caused incorrect values to be displayed
- Fixed an issue where scheduled publish options would disappear on autosave collections
- Fixed the OrderableTable component to respect custom API routes from config
- Allowed indentation of children elements in rich text even when their parent nodes are not indentable
- Fixed a typo in an error message and removed an unnecessary console.log
Database Fixes
- Fixed PostgreSQL schema generator to use the correct export path for codegen
- Fixed an issue where text fields were being converted to floating point numbers in SQLite
Other Fixes
- Added missing Catalan translations
- Fixed a missing default value in select field templates
New Features
Virtual Relationship Fields
Added support for virtual fields linked with relationship fields that are queryable, sortable, and can be used as titles. This allows you to define fields that automatically pull data from related collections without requiring depth parameters.
{
name: 'postTitle',
type: 'text',
virtual: 'post.title',
}
Relationship Field List Drawer
Added a new selectionType option for relationship fields that allows using a list drawer interface instead of the default dropdown. This provides advanced filtering and searching capabilities when selecting related documents.
Reusable Auth Server Functions
Added exportable server functions for login, logout, and refresh that are fully typed and handle cookies internally, simplifying authentication in server-side code.
Operation Context in Field Conditions
Field condition functions now receive an operation argument that provides context about which operation is currently being executed, allowing for more granular conditional logic.
PostgreSQL Client Injection
Added the ability to inject a custom PostgreSQL client in @payloadcms/db-postgres, enabling Sentry instrumentation of database queries.
Security Updates
No specific security fixes were mentioned in this release.
Performance Improvements
Network Optimization
Prevented blockType: "$undefined" from being sent through the network when sending form state requests, reducing request size.
API View Performance
Added support for respecting the defaultDepth setting in the admin UI API view, which can prevent performance issues when dealing with documents that have many large related documents.
Development Environment
Improved the development environment by assigning available ports to environment variables, ensuring that hot module replacement (HMR) works correctly when the default port is already in use.
Impact Summary
PayloadCMS v3.35.0 delivers significant improvements for both developers and content editors. The introduction of queryable virtual relationship fields solves a common development challenge by allowing fields to automatically pull and display data from related collections without requiring depth parameters. This feature greatly simplifies querying and sorting based on related data.
The new relationship field list drawer provides a much-improved interface for selecting related items, especially when dealing with large collections or complex relationships where the standard dropdown is insufficient. Content editors will appreciate the advanced filtering and search capabilities this brings.
For developers building server-side applications, the new reusable auth server functions eliminate the complexity of manually handling cookies and JWT tokens, making authentication implementation more straightforward and less error-prone.
The fix for data loss when reordering draft documents addresses a critical issue that could have caused significant problems in production environments. Similarly, the CORS headers fix for custom endpoints resolves an important integration issue.
Overall, this release enhances both developer experience and end-user functionality while fixing several important bugs, making it a recommended upgrade for all PayloadCMS users.
Full Release Notes
🚀 Features
- queriable / sortable /
useAsTitle virtual fields linked with a relationship field (#11805) (1c99f46)
- threads operation through field condition function (#12132) (c877b1a)
- adds and exports reusable auth server functions (#11900) (6b34937)
- db-postgres: dependency inject pg to allow Sentry instrumentation (#11478) (da7be35)
- ui: add option for rendering the relationship field as list drawer (#11553) (55d00e2)
- ui: use defaultDepth in API view (#11950) (b354d00)
🐛 Bug Fixes
- respects boolean query preset constraints (#12124) (a675c04)
- ensures cors headers are run against custom endpoints (#12091) (e79b203)
- reordering draft documents causes data loss (#12109) (e90ff72)
- correct typo in error message and remove console.log (#12082) (a9eca3a)
- db-postgres: use correct export path for codegen in
createSchemaGenerator (#12043) (71e3c78)
- db-sqlite: text field converts to floating point number (#12107) (6572bf4)
- richtext-lexical: allow to indent children even if their parents are not indentable (#12042) (babf4f9)
- templates: missing default value in select field (#11715) (5b554e5)
- translations: add missing Catalan translations (#10682) (85e6edf)
- ui: stale paths on custom components within rows (#11973) (21599b8)
- ui: issue with schedule publish disappearing on autosave collections (#12078) (3a7cd71)
- ui: use route.api from config in OrderableTable (#12081) (3287f70)
⚡ Performance
- ui: prevent
blockType: "$undefined" from being sent through the network (#12131) (4426625)
📚 Documentation
🏡 Chores
- adjusts ChevronIcon styling to match other icons (#12133) (2362899)
- assign available port to env variable in dev suite (#12092) (39462bc)
- separate Lexical tests into dedicated suite (#12047) (a66f90e)
🤝 Contributors