parse-community / parse-community/parse-server
While using afterFind hook, including self does not work.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 21.4k
- Forks
- 4.8k
- Avg merge
- 7h 45m
- Merged PRs (30d)
- 11
Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest version of Parse Server.
Issue Description
case: We have a products collection where we link the variant to the mainProduct, but wherever there is no variant we add the mainProduct only to the field as a pointer, when we query on it we include mainProduct in the query it used to work fine, it used to add mainProduct details in current product while returning to frontend, but recently we have added a afterFind hook and the include is not working even if we keep afterFind empty it still don't work, it is always gives mainProduct as pointer only. it should either be always including whether there is a afterFind or no afterFind or never include same object.
Steps to reproduce
- Create a parse object
- set a field with any name and set pointer to self in that field
- now do a query from frontend and include that field
- you will see the object is now included and you can access all fields on that object
- now go to backend and add a afterFind hook for the same class, do nothing there just return req.objects
- run the same query again and now it included object is not included it is still a pointer.
Actual Outcome
Object including the same object when there is no afterFind, but as soon as a afterFind hook is added it gives it as a pointer only.
Expected Outcome
if it is a issue because i am including same object in same object, it should have happened in both cases with or without afterFind. afterFind should not change the behaviour of how include works.
Failing Test Case / Pull Request
- 🤩 I submitted a PR with a fix and a test case.
- 🧐 I submitted a PR with a failing test case.
Environment
Server
- Parse Server version: 4.5.0
- Operating system: Ubuntu 18.04
- Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
Azure
Database
- System (MongoDB or Postgres):
MongoDB - Database version:
4.2 - Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc):
Azure
Client
- SDK (iOS, Android, JavaScript, PHP, Unity, etc):
JavaScript - SDK version:
3.1
Logs
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with a self-referential pointer, an include query, and an empty afterFind hook as described in the steps. Compare the returned object with and without afterFind; done means the include behavior is consistent in both cases and is covered by a failing and passing test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mongodb, nodejs
- Domain
- api, backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100