Skip to content

Commit a6bbd49

Browse files
authored
fix(LiveQuery): Allow connect with null fields (#1282)
1 parent a0b2561 commit a6bbd49

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

integration/test/ParseLiveQueryTest.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,32 @@ describe('Parse LiveQuery', () => {
5858
await object.save();
5959
});
6060

61+
it('can subscribe to query with null connect fields', async done => {
62+
const client = new Parse.LiveQueryClient({
63+
applicationId: 'integration',
64+
serverURL: 'ws://localhost:1337',
65+
javascriptKey: null,
66+
masterKey: null,
67+
sessionToken: null,
68+
installationId: null,
69+
});
70+
client.open();
71+
const object = new TestObject();
72+
await object.save();
73+
74+
const query = new Parse.Query(TestObject);
75+
query.equalTo('objectId', object.id);
76+
const subscription = await client.subscribe(query);
77+
subscription.on('update', async object => {
78+
assert.equal(object.get('foo'), 'bar');
79+
client.close();
80+
done();
81+
});
82+
await subscription.subscribePromise;
83+
object.set({ foo: 'bar' });
84+
await object.save();
85+
});
86+
6187
it('can subscribe to multiple queries', async () => {
6288
const objectA = new TestObject();
6389
const objectB = new TestObject();

src/LiveQueryClient.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ class LiveQueryClient extends EventEmitter {
160160
this.requestId = 1;
161161
this.serverURL = serverURL;
162162
this.applicationId = applicationId;
163-
this.javascriptKey = javascriptKey;
164-
this.masterKey = masterKey;
163+
this.javascriptKey = javascriptKey || undefined;
164+
this.masterKey = masterKey || undefined;
165165
this.sessionToken = sessionToken || undefined;
166-
this.installationId = installationId;
166+
this.installationId = installationId || undefined;
167167
this.additionalProperties = true;
168168
this.connectPromise = resolvingPromise();
169169
this.subscriptions = new Map();

0 commit comments

Comments
 (0)