fix(sdk): pass trash to request#16092
Merged
PatrikKozak merged 4 commits intopayloadcms:mainfrom Mar 30, 2026
Merged
Conversation
r1tsuu
requested changes
Mar 29, 2026
Member
r1tsuu
left a comment
There was a problem hiding this comment.
Thanks! Add an integration test for this in test/sdk/int.spec.ts please
Contributor
Author
Done. |
r1tsuu
approved these changes
Mar 30, 2026
PatrikKozak
approved these changes
Mar 30, 2026
Contributor
|
🚀 This is included in version v3.81.0 |
milamer
pushed a commit
to milamer/payload
that referenced
this pull request
Apr 20, 2026
### 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
The REST SDK documents a
trashoption onfind,findVersions, andfindVersionByID, but that flag was never added to the request URL. The Local API and REST handlers already supporttrashvia query params (parseParams/ collection endpoints).Why?
Users enabling soft delete (trash) need
trash: trueon list/version queries to include trashed documents (or to query the trash view). Passingtrashfrom the SDK had no effect becausebuildSearchParamsomitted it, so the REST API always behaved as iftrashwas unset.How?
OperationArgsinpackages/sdk/src/utilities/buildSearchParams.tswith optionaltrash?: boolean.trashis a boolean, serialize it to the query string (same pattern asdraft).test/sdk/int.spec.tsthat uses a stubfetchand asserts the requested URL containstrash=trueforfind,findVersions, andfindVersionByID.Before:
sdk.find({ collection: 'posts', trash: true })→ request had notrashquery param.After: same call →
...?trash=true&...(alongside other params).Fixes #