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 suite
spec/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 API
src/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 handling
src/LiveQuery/ParseLiveQueryServer.ts
Adds routing for op: 'query' and an async _handleQuery method: validates client and subscription, chooses auth (`subscription.sessionToken
Request Schema: query op
src/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
Loading

Estimated code review effort

๐ŸŽฏ 3 (Moderate) | โฑ๏ธ ~25 minutes

  • Verify authentication selection and fallback (subscription.sessionToken โ†’ client.sessionToken โ†’ master key) in src/LiveQuery/ParseLiveQueryServer.ts.
  • Confirm _pushQueryResult in src/LiveQuery/Client.js applies per-subscription keys consistently with _toJSONWithFields.
  • Inspect new tests in spec/ParseLiveQueryQuery.spec.js for 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

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 2a7ad48 and 466d789.

๐Ÿ“’ 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.

โค๏ธ Share

Comment @coderabbitai help to get the list of available commands and usage tips.