Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break js-data relations when JsonApi related data changes or becomes Null or Empty #10

Open
BlairAllegroTech opened this issue Jun 28, 2016 · 2 comments

Comments

@BlairAllegroTech
Copy link
Owner

BlairAllegroTech commented Jun 28, 2016

js-data maintains data relationships.

If however other changes are being made against the server and we then request a resource that subsequently returns relationship data that differs from the js-data data store, we should try to update the datastore to keep it in sync?

Should we try to do this or leave to the developer to keep things in sync ??
See also #9

Cases:

  • We request a to one related field and it returns null (from the server).
    • Clear the local key on the parent object
  • We request a toMany relationship that returns an empty array
    • Clear all foreign keys on foreign objects
BlairAllegroTech pushed a commit that referenced this issue Jul 6, 2016
 - No longer initialise jsonapi response parameters unless they are used (updated related tests)
 - When searching for relations always search lower case relation names
 - When JsonApi response contains null or empty data de serialize as an empty array
 - Update findRelated to take anadditional options parameter, to force loading of relation.
 - findRelated JsonApi relationship path no placedin options rather than HTTP params
 - setParentIds now also appends id field to link url, previously omitted
BlairAllegroTech added a commit that referenced this issue Jul 28, 2016
@BlairAllegroTech
Copy link
Owner Author

Related to #42

@rgant
Copy link
Contributor

rgant commented Feb 17, 2017

I definitely think that the server is the source of truth and so if we get differing information back from the server then js-data should respect that.

I've recently had to add onConflict: 'replace' to my DS#save and DS#find calls so that it doesn't try to merge nested objects an create problems for my app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants