Skip to content

Add support for fields in LiveQuery #3671

@rogerhu

Description

@rogerhu

Issue Description

Parse LiveQuery specifications are supposed to take a fields in the query. Parse server does not handle these fields, nor do the iOS and Android clients.

https://github.com/ParsePlatform/parse-server/wiki/Parse-LiveQuery-Protocol-Specification

{
  "op": "subscribe",
  "requestId": 1,
  "query": {
      "className": "Player",
      "where": {"name": "test"},
      "fields": ["name"] // Optional
  },
  "sessionToken": "" // Optional
}

https://github.com/ParsePlatform/ParseLiveQuery-iOS-OSX/blob/master/Sources/ParseLiveQuery/Internal/QueryEncoder.swift

parse-community/ParseLiveQuery-Android#18

Steps to reproduce

Create a Parse Query with fields:


@ParseClassName("Message")
public class Message extends ParseObject {
    public static final String USER_ID_KEY = "userId";
    public static final String BODY_KEY = "body";

    public String getUserId() {
        return getString(USER_ID_KEY);
    }

    public String getBody() {
        return getString(BODY_KEY);
    }

    public void setUserId(String userId) {
        put(USER_ID_KEY, userId);
    }

    public void setBody(String body) {
        put(BODY_KEY, body);
    }
}
ParseLiveQueryClient<Message> parseLiveQueryClient =
                    ParseLiveQueryClient.Factory.getClient(new URI(ChatApplication.wsURI));

ParseQuery<Message> parseQuery = ParseQuery.getQuery(Message.class);
parseQuery.selectKeys(["userId"]);

            SubscriptionHandling<Message> subscriptionHandling = parseLiveQueryClient.subscribe(parseQuery);
            subscriptionHandling.handleEvents(
   new SubscriptionHandling.HandleEventsCallback<Message>() {
                        @Override
                        public void onEvents(ParseQuery<Message> query,
                                SubscriptionHandling.Event event,
                                Message object)
                        {
          }
}

Expected Results

Expect only fields to come out.

Actual Outcome

All fields are returned.

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 2.3.7
    • Operating System: MacOS
    • Hardware: [FILL THIS OUT]
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): localhost, Heroku
  • Database

    • MongoDB version: 3.2.1

Logs/Trace

Include all relevant logs. You can turn on additional logging by configuring VERBOSE=1 in your environment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions