SIGN IN SIGN UP
payloadcms / payload UNCLAIMED

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.

0 0 16 TypeScript

fix(sdk): pass trash to request (#16092)

### What?

The REST SDK documents a `trash` option on `find`, `findVersions`, and
`findVersionByID`, but that flag was never added to the request URL. The
Local API and REST handlers already support `trash` via query params
(`parseParams` / collection endpoints).

### Why?

Users enabling [soft delete
(trash)](https://payloadcms.com/docs/trash/overview) need `trash: true`
on list/version queries to include trashed documents (or to query the
trash view). Passing `trash` from the SDK had no effect because
`buildSearchParams` omitted it, so the REST API always behaved as if
`trash` was unset.

### How?

- Extended `OperationArgs` in
`packages/sdk/src/utilities/buildSearchParams.ts` with optional `trash?:
boolean`.
- When `trash` is a boolean, serialize it to the query string (same
pattern as `draft`).
- Added an integration test in `test/sdk/int.spec.ts` that uses a stub
`fetch` and asserts the requested URL contains `trash=true` for `find`,
`findVersions`, and `findVersionByID`.

**Before:** `sdk.find({ collection: 'posts', trash: true })` → request
had no `trash` query param.

**After:** same call → `...?trash=true&...` (alongside other params).

Fixes #

---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1213864434332542

---------

Co-authored-by: Sasha Rakhmatulin <sasha@ritsuko.dev>
N
Nathan Bo Wang committed
e0b3e81f316050203e8ef293a7004160dd2eaa30
Parent: 727d74e
Committed by GitHub <noreply@github.com> on 3/30/2026, 1:15:21 PM