Skip to content

include={field} not working on specific object request #1124

Closed
@nkranes

Description

@nkranes

For implementation related questions or technical support, please refer to the Stack Overflow and Server Fault communities.

Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Server!

Environment Setup

parse-server running locally

Steps to reproduce

1 - Insert a class
curl -X POST -H "X-Parse-Application-Id: XXXX" -H "Content-Type: application/json" -H "X-Parse-Master-Key: XXXX" -d '{
"platform" : "Android",
"isMerged" : "true"
}' "http://localhost:1337/parse/classes/AppConfig"

ObjectId: uq9RVGSIrv

2 - Insert another class
curl -X POST -H "X-Parse-Application-Id: XXXX" -H "Content-Type: application/json" -H "X-Parse-Master-Key: XXXX" -d '{
"name" : "John Smith",
"streetAddress" : "123 Main St"
}' "http://localhost:1337/parse/classes/Player"

ObjectId: UoBKuO29mp

3 - Insert a few types of relations between the 2 classes, since I'm not sure what the correct syntax is
curl -X PUT -H "X-Parse-Application-Id: XXXX" -H "Content-Type: application/json" -H "X-Parse-Master-Key: XXXX" -d '{"player":{"__op":"AddUnique","objects":[{"__type":"Pointer","className":"Player","objectId":"UoBKuO29mp"}]}}
' "http://localhost:1337/parse/classes/AppConfig/uq9RVGSIrv"

curl -X PUT -H "X-Parse-Application-Id: XXXX" -H "Content-Type: application/json" -H "X-Parse-Master-Key: XXXX" -d '{"player2":{"__op":"AddRelation","objects":[{"__type":"Pointer","className":"Player","objectId":"UoBKuO29mp"}]}}
' "http://localhost:1337/parse/classes/AppConfig/uq9RVGSIrv"

curl -X PUT -H "X-Parse-Application-Id: XXXX" -H "Content-Type: application/json" -d '{"player3":{"__op":"Add","objects":[{"__type":"Pointer","className":"Player","objectId":"UoBKuO29mp"}]}}
' "http://localhost:1337/parse/classes/AppConfig/uq9RVGSIrv"

curl -X POST -H "X-Parse-Application-Id: XXXX" -H "Content-Type: application/json" -d '{"Level" : "TWO", "player4":{"__op":"AddUnique","objects":[{"__type":"Pointer","className":"Player","objectId":"UoBKuO29mp"}]}}
' "http://localhost:1337/parse/classes/AppConfig"

4 - Get the AppConfig object and notice the "include=" does not work
curl -X GET -H "X-Parse-Application-Id: XXXX" -H "Content-Type: application/json" "http://localhost:1337/parse/classes/AppConfig/uq9RVGSIrv?include=player"

Results:

{
  "objectId": "uq9RVGSIrv",
  "platform": "Android",
  "isMerged": "true",
  "updatedAt": "2016-03-21T17:47:11.682Z",
  "createdAt": "2016-03-21T16:56:14.816Z",
  "player": [
    {
      "__type": "Pointer",
      "className": "Player",
      "objectId": "UoBKuO29mp"
    }
  ],
  "player3": [
    {
      "__type": "Pointer",
      "className": "Player",
      "objectId": "UoBKuO29mp"
    }
  ]
}

5 - Get rid of the objectId in the query and it works as expected
curl -X GET -H "X-Parse-Application-Id: XXXX" -H "Content-Type: application/json" "http://localhost:1337/parse/classes/AppConfig?include=player"

{
  "results": [
    {
      "objectId": "uq9RVGSIrv",
      "platform": "Android",
      "isMerged": "true",
      "updatedAt": "2016-03-21T17:47:11.682Z",
      "createdAt": "2016-03-21T16:56:14.816Z",
      "player": [
        {
          "objectId": "UoBKuO29mp",
          "name": "John Smith",
          "streetAddress": "123 Main St",
          "updatedAt": "2016-03-21T16:54:44.271Z",
          "createdAt": "2016-03-21T16:54:44.271Z",
          "__type": "Object",
          "className": "Player"
        }
      ],
      "player3": [
        {
          "__type": "Pointer",
          "className": "Player",
          "objectId": "UoBKuO29mp"
        }
      ]
    },
    {
      "objectId": "UvBVu5EKB3",
      "Level": "TWO",
      "player4": [
        {
          "__type": "Pointer",
          "className": "Player",
          "objectId": "UoBKuO29mp"
        }
      ],
      "updatedAt": "2016-03-21T17:49:20.945Z",
      "createdAt": "2016-03-21T17:49:20.945Z"
    }
  ]
}

OR

curl -X GET -H "X-Parse-Application-Id: XXXX" -H "Content-Type: application/json" "http://localhost:1337/parse/classes/AppConfig?include=player&include=player4&include=player3"

{
  "results": [
    {
      "objectId": "uq9RVGSIrv",
      "platform": "Android",
      "isMerged": "true",
      "updatedAt": "2016-03-21T17:47:11.682Z",
      "createdAt": "2016-03-21T16:56:14.816Z",
      "player": [
        {
          "objectId": "UoBKuO29mp",
          "name": "John Smith",
          "streetAddress": "123 Main St",
          "updatedAt": "2016-03-21T16:54:44.271Z",
          "createdAt": "2016-03-21T16:54:44.271Z",
          "__type": "Object",
          "className": "Player"
        }
      ],
      "player3": [
        {
          "objectId": "UoBKuO29mp",
          "name": "John Smith",
          "streetAddress": "123 Main St",
          "updatedAt": "2016-03-21T16:54:44.271Z",
          "createdAt": "2016-03-21T16:54:44.271Z",
          "__type": "Object",
          "className": "Player"
        }
      ]
    },
    {
      "objectId": "UvBVu5EKB3",
      "Level": "TWO",
      "player4": [
        {
          "objectId": "UoBKuO29mp",
          "name": "John Smith",
          "streetAddress": "123 Main St",
          "updatedAt": "2016-03-21T16:54:44.271Z",
          "createdAt": "2016-03-21T16:54:44.271Z",
          "__type": "Object",
          "className": "Player"
        }
      ],
      "updatedAt": "2016-03-21T17:49:20.945Z",
      "createdAt": "2016-03-21T17:49:20.945Z"
    }
  ]
}

I think this is not the expected behavior.

Thanks!

Logs/Trace

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