feat: queryAll, queryMore, and full-result pagination - #49
Merged
Conversation
Add a "Running SOQL Queries" section covering executeQuery/executeQueryAll, manual queryMore pagination, and getAllRecords full-result fetching.
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.
Summary
Adds first-class support for the Salesforce
queryAllresource and cursor-based pagination (queryMore), plus a convenience wrapper that transparently fetches an entire result set across all pages.Salesforce returns query results in batches (up to 2,000 records). To retrieve everything you must follow the
nextRecordsUrlcursor returned on each response untildoneistrue. This PR wires that up end to end.What's new
executeQueryAll($builder)/executeQueryAllRaw($rawQuery)— run SOQL against thequeryAllendpoint, which also returns soft-deleted and archived records.queryMore($nextRecordsUrl)— fetch the next batch of records using thenextRecordsUrlfrom a prior response. Works for bothqueryandqueryAllresults.getAllRecords($builder, $includeDeleted = false)/getAllRecordsRaw($rawQuery, $includeDeleted = false)— follow pagination until Salesforce reportsdone, returning the complete result set as a single array. Pass$includeDeleted = trueto page through thequeryAllendpoint.Implementation notes
QueryMorerequest strips the/services/data/v{XX.X}prefix fromnextRecordsUrlbefore resolving the endpoint, because the Saloon connector base URL already includes it (absolute URLs are not permitted).queryAllrequest returns anextRecordsUrlcontaining/query/(not/queryAll/) — it still serves the remaining results from the originalqueryAll.QueryMorehandles either path transparently.stripAttributes()helper so record-attribute stripping is no longer duplicated betweenunpackResponseIfNeeded()and the pagination path.getAllRecords*reads the raw response so it can seedone/nextRecordsUrl; note that enablingrecordsOnly()strips this metadata, so manualqueryMorepagination requires it to be off.Salesforce reference
qparameter, thetotalSize/done/nextRecordsUrl/recordsresponse shape, the/query/form of thequeryAllcursor, and the 2,000-record batch limit.Tests
tests/QueryMoreTest.phpcovering:nextRecordsUrlprefix stripping (query, queryAll, and fully-qualified forms using the real doc example value), multi-page pagination, single-page short-circuit,queryAllendpoint routing, andqueryMorerequest resolution.Docs
executeQuery/executeQueryAll, manualqueryMorepagination (with therecordsOnly()caveat), andgetAllRecordsfull-fetch (with a memory note pointing to the Bulk API for very large exports).