Pitfall: Parse Circular Dependency Error and Bidirectional Relationship
When you save a
PFObject and encounter the error
Found a circular dependency when saving, it could be due to you setting a bidirectional/inverse relationship.
Take this example:
1 2 3 4 5
Upon save, the code will throw the exception
Found a circular dependency when saving. This is because bidirectional relationship is not supported on Parse.
The solution requires 3 steps:
- Don’t set up any of the relationship, and save
teacherfirst. Saving will provide
- Then save
studentwith 1 directional relationship to
teacher. Saving will provide
- Then update
teacherwith the relation to
This takes 3 API requests to set up.
Not good, but workaround the limitation of Parse.