Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/LiveQueryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ class LiveQueryClient {
* <a href="https://github.com/parse-community/parse-server/wiki/Parse-LiveQuery-Protocol-Specification">here</a> for more details. The subscription you get is the same subscription you get
* from our Standard API.
*
* @param {ParseQuery} query - the ParseQuery you want to subscribe to
* @param {string} sessionToken (optional)
* @param {ParseQuery} query The `Parse.Query` to subscribe to.
* @param {string} [sessionToken] Optional session token to use for the subscription.
* @returns {LiveQuerySubscription | undefined}
*/
subscribe(query: ParseQuery, sessionToken?: string): LiveQuerySubscription | undefined {
Expand All @@ -196,6 +196,7 @@ class LiveQueryClient {
const where = queryJSON.where;
const keys = queryJSON.keys?.split(',');
const watch = queryJSON.watch?.split(',');
const include = queryJSON.include?.split(',');
const subscribeRequest = {
op: OP_TYPES.SUBSCRIBE,
requestId: this.requestId,
Expand All @@ -204,6 +205,7 @@ class LiveQueryClient {
where,
keys,
watch,
include,
},
sessionToken: undefined as string | undefined,
};
Expand Down Expand Up @@ -294,6 +296,7 @@ class LiveQueryClient {
const where = queryJSON.where;
const keys = queryJSON.keys?.split(',');
const watch = queryJSON.watch?.split(',');
const include = queryJSON.include?.split(',');
const className = query.className;
const sessionToken = subscription.sessionToken;
const subscribeRequest = {
Expand All @@ -304,6 +307,7 @@ class LiveQueryClient {
where,
keys,
watch,
include,
},
sessionToken: undefined as string | undefined,
};
Expand Down
8 changes: 8 additions & 0 deletions src/__tests__/LiveQueryClient-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@ describe('LiveQueryClient', () => {
};
const query = new ParseQuery('Test');
query.equalTo('key', 'value');
query.include(['key']);

const subscribePromise = liveQueryClient.subscribe(query);
const clientSub = liveQueryClient.subscriptions.get(1);
Expand All @@ -809,6 +810,7 @@ describe('LiveQueryClient', () => {
where: {
key: 'value',
},
include: ['key'],
},
});
});
Expand All @@ -826,6 +828,7 @@ describe('LiveQueryClient', () => {
};
const query = new ParseQuery('Test');
query.equalTo('key', 'value');
query.include(['key']);

const subscribePromise = liveQueryClient.subscribe(query, 'mySessionToken');
const clientSub = liveQueryClient.subscriptions.get(1);
Expand All @@ -848,6 +851,7 @@ describe('LiveQueryClient', () => {
where: {
key: 'value',
},
include: ['key'],
},
});
});
Expand Down Expand Up @@ -946,6 +950,7 @@ describe('LiveQueryClient', () => {
query.equalTo('key', 'value');
query.select(['key']);
query.watch(['key']);
query.include(['key']);
liveQueryClient.subscribe(query);
liveQueryClient.connectPromise.resolve();

Expand All @@ -965,6 +970,7 @@ describe('LiveQueryClient', () => {
},
keys: ['key'],
watch: ['key'],
include: ['key'],
},
});
});
Expand All @@ -984,6 +990,7 @@ describe('LiveQueryClient', () => {
query.equalTo('key', 'value');
query.select(['key']);
query.watch(['key']);
query.include(['key']);
liveQueryClient.subscribe(query, 'mySessionToken');
liveQueryClient.connectPromise.resolve();

Expand All @@ -1004,6 +1011,7 @@ describe('LiveQueryClient', () => {
},
keys: ['key'],
watch: ['key'],
include: ['key'],
},
});
});
Expand Down
4 changes: 2 additions & 2 deletions types/LiveQueryClient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ declare class LiveQueryClient {
* <a href="https://github.com/parse-community/parse-server/wiki/Parse-LiveQuery-Protocol-Specification">here</a> for more details. The subscription you get is the same subscription you get
* from our Standard API.
*
* @param {ParseQuery} query - the ParseQuery you want to subscribe to
* @param {string} sessionToken (optional)
* @param {ParseQuery} query The `Parse.Query` to subscribe to.
* @param {string} [sessionToken] Optional session token to use for the subscription.
* @returns {LiveQuerySubscription | undefined}
*/
subscribe(query: ParseQuery, sessionToken?: string): LiveQuerySubscription | undefined;
Expand Down