Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
perf: ensure deepCopy in beforeValidate hook does not run unnecessarily for rest and graphQL API (#10666)
Previously, the beforeValidate hook was deepCopying input data. This indirectly ensured that the passed input data was not mutated. E.g., if you run the `payload.create` local API, you do not want that to mutate the `data` object that is passed as an argument. This will create issues if you attempt to use it multiple times. This PR moves the deepCopy logic from the beforeValidate hook to the start of the local API operation. This ensures that - Input data is intentionally copied at the beginning which makes more sense. Comment was added to explain why - GraphQL and Rest operations are now faster, as we don't need to ensure that the input data is not mutated for those => deepCopy only runs for local API
A
Alessio Gravili committed
b69fe99ebea1115c0ec0fa7280c21027026efd02
Parent: c07c9e9
Committed by GitHub <noreply@github.com>
on 1/20/2025, 7:35:29 PM