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
Define a semantics for "side-deleting" #18
Comments
Personally I'm in favour of having some names within // id-style
meta: {
deleted: {
posts: [1,2,3],
people: [1,2]
}
}
// url-style
meta: {
deleted: {
posts: ["http://example.com/posts/1", "http://example.com/posts/2", "http://example.com/posts/3"],
people: ["http://example.com/people/1", "http://example.com/people/2"]
}
}
// url-style with templates
meta: {
urls: {
posts: "http://example.com/posts/{posts.id}",
people: "http://example.com/people/{people.id}"
},
deleted: {
posts: [1,2,3],
people: [1,2]
}
} |
Tell me guys if I am out of my mind, but would it be possible to return a json-patch format from server? |
Nope, that is 100% possible. |
One issue with a json-patch format (as much as I'd like it) is the One choice for this document is the primary document that would have been returned for a But what if the client hadn't already fetched that, and now can't because it's deleted? The client is unable to interpret the Just using explicit collections (keys under |
I suppose an alternative is for the spec to define a virtual master document, never (at least not required to be) instantiated. This document would need to contain all resources in the system in their respective collections, but with the collections represented as objects with resource identifiers (ids or urls) as members, rather than being lists. So e.g. in our example above the master document would contain, among other things:
Given that master document, the side-deletes could be represented as a json-patch sequence interpreted in the context of that document:
I feel like this just complicates the spec (introduction of the "master document") while still repeating the same information from @hjdivad's proposal (now embedded in the |
If I'm reading this right, we're trying to give the server a way to inform the client if the server knows about things that have been deleted and it thinks the client doesn't know they're deleted yet. So any request at all could return this deleted information. That sounds a lot like it's violating the whole statelessness aspect. Am I missing something? This sounds... incredibly fragile. |
I think that's where it started and the angle that many examples (including mine) came from. But I agree with you there; we should keep client state (what changes on the server doesn't the client know about yet?) away from the server. See #34 for a discussion around ways we might handle app staleness without client state on the server. So yeah, I recommend removing that portion of this discussion here. However, there may still be cases where a |
@paddyforan No, absolutely not. Having the server understand client state is a recipe for sadness. In fact I don't think that's where the discussion even started. @tchak's referenced ember-data pull-request exists for the server to inform clients of documents deleted as a result of the request. A common case is a |
Ah, so DELETE Sorry for the confusion. That sounds totally reasonable. Ignore me. |
@tchak I'm not sure if this is a good idea.
Directly quoted from my own comment in emberjs/data#962 |
@heartsentwined I think the only use case we're discussing here is a server responding with records that have been deleted as a result of the request (although nothing prevents the server from informing clients of other deleted records). This is unlikely to be expensive, as the server has to compute these records anyway to figure out who to delete. Remember that jsonapi is about having a standard way of handling the common use cases, and a well understood extension mechanism (eg |
@heartsentwined Well a query to get deleted records could be as simple as : |
@hjdivad @tchak well what I mean is that, while a single query would not be expensive as @tchak pointed out, adding this to every single request would be rather overkill for me. The expensive part is that they can never be served from a cache. A general |
@heartsentwined agreed. We newer talked about adding it to every request. In my case I use it with |
I would recommend using the Patch extension for performing multiple operations in a single request. |
@dgeb I am not sure I seen examples of responses with json-patch format in the current documentation. Only requests. Should we add some ? |
see emberjs/data#379
The text was updated successfully, but these errors were encountered: