feature: run query via livequery by dblythy ยท Pull Request #9864 ยท parse-community/parse-server
๐ Walkthrough
Walkthrough
Adds a LiveQuery "query" operation: request schema, server handler to execute find queries and return results, client API to push query results, and tests validating result delivery, field selection, where constraints, and error paths.
Changes
| Cohort / File(s) | Summary |
|---|---|
Tests: ParseLiveQuery query suitespec/ParseLiveQueryQuery.spec.js |
New Jasmine spec exercising LiveQuery query requests: success path with multiple objects, keys-based field filtering, where constraints, missing clientId/subscription error reporting, and helper mocks for clients/subscriptions. |
LiveQuery Client: push result APIsrc/LiveQuery/Client.js |
Adds pushResult (bound to _pushQueryResult) that builds op: 'result' messages including clientId, installationId, and requestId; maps results through _toJSONWithFields using per-subscription keys and sends via pushResponse. |
LiveQuery Server: query op handlingsrc/LiveQuery/ParseLiveQueryServer.ts |
Adds routing for op: 'query' and an async _handleQuery method: validates client and subscription, chooses auth (`subscription.sessionToken |
Request Schema: query opsrc/LiveQuery/RequestSchema.js |
Adds query operation schema and registers RequestSchema.query with op: 'query' and numeric requestId. |
Sequence Diagram(s)
sequenceDiagram
autonumber
participant SDK as LiveQuery Client SDK
participant WS as WebSocket Server
participant Srv as ParseLiveQueryServer
participant Sub as Subscription Registry
participant DB as Data Store
rect rgba(230,240,255,0.35)
note left of SDK: client sends a query tied to a subscriptionId
end
SDK->>WS: { op: "query", requestId, id: subscriptionId, where, keys }
WS->>Srv: route "query" request
Srv->>Sub: lookup subscription(subscriptionId)
alt subscription found
Srv->>Srv: resolve auth (subscription.sessionToken || client.sessionToken || master)
Srv->>DB: find(className, where, keys)
DB-->>Srv: results[]
Srv->>WS: push { op: "result", requestId, clientId, installationId, results }
WS-->>SDK: deliver "result"
else subscription missing
Srv->>WS: push error { op: "error", requestId, ... }
WS-->>SDK: deliver error
end
Estimated code review effort
๐ฏ 3 (Moderate) | โฑ๏ธ ~25 minutes
- Verify authentication selection and fallback (
subscription.sessionTokenโclient.sessionTokenโ master key) insrc/LiveQuery/ParseLiveQueryServer.ts. - Confirm
_pushQueryResultinsrc/LiveQuery/Client.jsapplies per-subscriptionkeysconsistently with_toJSONWithFields. - Inspect new tests in
spec/ParseLiveQueryQuery.spec.jsfor proper mock setup/teardown and correctness of error-case assertions.
Pre-merge checks and finishing touches
โ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | โ ๏ธ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
โ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title Check | โ Passed | The title "feature: run query via livequery" accurately and specifically describes the main change in this pull request. It clearly conveys that a new query feature is being added to LiveQuery functionality, which aligns directly with the substantial changes across the request schema, server handler, and client result-pushing mechanism. The title is concise, free of noise, and specific enough for developers scanning history to quickly understand the primary contribution. |
| Linked Issues Check | โ Passed | The code changes successfully implement the primary server-side requirements from issue #9086. The implementation enables running queries through LiveQuery subscriptions, adds a new "query" request operation to the schema, implements the server-side handler (_handleQuery in ParseLiveQueryServer), and provides the mechanism for pushing results back to clients (pushResult in Client.js). The comprehensive test suite validates query handling with existing subscriptions, field filtering (keys), and where constraints. The implementation achieves the core objective of enabling initial data sync over WebSocket to eliminate separate REST API calls, and the test coverage confirms the functionality works correctly. Client SDK changes required for complete end-to-end functionality are acknowledged in the PR description as separate work items. |
| Out of Scope Changes Check | โ Passed | All code changes in this pull request are directly aligned with the feature objective of adding query support to LiveQuery. The new test file (spec/ParseLiveQueryQuery.spec.js) validates the query feature implementation; the Client.js modifications (pushResult method) enable result delivery through subscriptions; the ParseLiveQueryServer.ts addition (_handleQuery method) implements core query request handling; and the RequestSchema.js changes define the query operation schema. No unrelated refactoring, cleanup, or out-of-scope modifications are present in the changeset. |
| Description Check | โ Passed | The pull request description follows the required template structure with all critical sections populated: it includes the issue closure link (#9086), provides a brief but meaningful explanation of the approach (adding a query operation to execute queries through WebSocket subscriptions and eliminating REST API calls), and marks the "Add tests" task as complete. While the approach section is somewhat concise, it conveys the essential intent of the feature. The description also appropriately acknowledges that client SDK changes are required as separate work. |
โจ Finishing touches
- ๐ Generate docstrings
๐งช Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
๐ Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
๐ Files selected for processing (1)
spec/ParseLiveQueryQuery.spec.js(1 hunks)
๐ง Files skipped from review as they are similar to previous changes (1)
- spec/ParseLiveQueryQuery.spec.js
โฐ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
- GitHub Check: PostgreSQL 15, PostGIS 3.3
- GitHub Check: PostgreSQL 16, PostGIS 3.5
- GitHub Check: Redis Cache
- GitHub Check: PostgreSQL 18, PostGIS 3.6
- GitHub Check: PostgreSQL 15, PostGIS 3.5
- GitHub Check: PostgreSQL 17, PostGIS 3.5
- GitHub Check: Node 20
- GitHub Check: PostgreSQL 15, PostGIS 3.4
- GitHub Check: Node 18
- GitHub Check: MongoDB 8, ReplicaSet
- GitHub Check: MongoDB 6, ReplicaSet
- GitHub Check: MongoDB 7, ReplicaSet
- GitHub Check: Docker Build
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.