feat: Deprecate LiveQuery fields option in favor of keys for semantic consistency (#8388)
This commit is contained in:
@@ -98,13 +98,13 @@ class Client {
|
||||
response['requestId'] = subscriptionId;
|
||||
}
|
||||
if (typeof parseObjectJSON !== 'undefined') {
|
||||
let fields;
|
||||
let keys;
|
||||
if (this.subscriptionInfos.has(subscriptionId)) {
|
||||
fields = this.subscriptionInfos.get(subscriptionId).fields;
|
||||
keys = this.subscriptionInfos.get(subscriptionId).keys;
|
||||
}
|
||||
response['object'] = this._toJSONWithFields(parseObjectJSON, fields);
|
||||
response['object'] = this._toJSONWithFields(parseObjectJSON, keys);
|
||||
if (parseOriginalObjectJSON) {
|
||||
response['original'] = this._toJSONWithFields(parseOriginalObjectJSON, fields);
|
||||
response['original'] = this._toJSONWithFields(parseOriginalObjectJSON, keys);
|
||||
}
|
||||
}
|
||||
Client.pushResponse(this.parseWebSocket, JSON.stringify(response));
|
||||
|
||||
@@ -23,6 +23,7 @@ import LRU from 'lru-cache';
|
||||
import UserRouter from '../Routers/UsersRouter';
|
||||
import DatabaseController from '../Controllers/DatabaseController';
|
||||
import { isDeepStrictEqual } from 'util';
|
||||
import Deprecator from '../Deprecator/Deprecator';
|
||||
|
||||
class ParseLiveQueryServer {
|
||||
clients: Map;
|
||||
@@ -850,9 +851,6 @@ class ParseLiveQueryServer {
|
||||
await runTrigger(trigger, `beforeSubscribe.${className}`, request, auth);
|
||||
|
||||
const query = request.query.toJSON();
|
||||
if (query.keys) {
|
||||
query.fields = query.keys.split(',');
|
||||
}
|
||||
request.query = query;
|
||||
}
|
||||
|
||||
@@ -901,8 +899,17 @@ class ParseLiveQueryServer {
|
||||
subscription: subscription,
|
||||
};
|
||||
// Add selected fields, sessionToken and installationId for this subscription if necessary
|
||||
if (request.query.keys) {
|
||||
subscriptionInfo.keys = Array.isArray(request.query.keys)
|
||||
? request.query.keys
|
||||
: request.query.keys.split(',');
|
||||
}
|
||||
if (request.query.fields) {
|
||||
subscriptionInfo.fields = request.query.fields;
|
||||
subscriptionInfo.keys = request.query.fields;
|
||||
Deprecator.logRuntimeDeprecation({
|
||||
usage: `Subscribing using fields parameter`,
|
||||
solution: `Subscribe using "keys" instead.`,
|
||||
});
|
||||
}
|
||||
if (request.query.watch) {
|
||||
subscriptionInfo.watch = request.query.watch;
|
||||
|
||||
@@ -70,6 +70,22 @@ const subscribe = {
|
||||
minItems: 1,
|
||||
uniqueItems: true,
|
||||
},
|
||||
keys: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
minItems: 1,
|
||||
uniqueItems: true,
|
||||
},
|
||||
watch: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
minItems: 1,
|
||||
uniqueItems: true,
|
||||
},
|
||||
},
|
||||
required: ['where', 'className'],
|
||||
additionalProperties: false,
|
||||
@@ -108,6 +124,22 @@ const update = {
|
||||
minItems: 1,
|
||||
uniqueItems: true,
|
||||
},
|
||||
keys: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
minItems: 1,
|
||||
uniqueItems: true,
|
||||
},
|
||||
watch: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
minItems: 1,
|
||||
uniqueItems: true,
|
||||
},
|
||||
},
|
||||
required: ['where', 'className'],
|
||||
additionalProperties: false,
|
||||
|
||||
Reference in New Issue
Block a user