-
Notifications
You must be signed in to change notification settings - Fork 830
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
Bulk operations without extensions #1625
Comments
Thanks a lot for proposing. Is your main point about not requiring an extension at all? Or only to avoid complexity of the Atomic Operations extension? #1380 proposes to add a bulk extension, which sounds very much like what you are asking for. |
I see Atomic Operations as a way to change resources with different resource types in bulk. What I meant with this issue is that it seems possible for me to add bulk for resources with the same resource type without changing the format of v1.0. So, this issue asks to leave out the restrictions of |
@jelhan I think you can remove the 'extension' label, because I don't want it to be an extension. I want it to be in 1.1 (or 1.2). |
I want to propose an improvement: Section 7.1 in JSONAPI 1.0; Section 9.1 in upcoming JSONAPI 1.1: OLD:
NEW:
And as Note:
Above proposal will cause that the rules of the document is the same, no matter the direction (server to client or client to server). At the moment that is not the case, because a server may return a |
The extension label express that this could be solved using an extension. It does not necessary mean that it most be solved using an extension. V1.1 is considered feature complete. There won't be any new feature added. So far I haven't seen a convincing argument why this needs to be added to the base spec. Going forward I would prefer having experiments in user space using extensions and profiles before adding to base spec. Such experiments should proof both: 1) That there is enough interest for the feature to be implemented in a noticeable number of libraries. 2) That it actually works in practice.
If it's not about transaction support, why not use separate requests in parallel? |
I will think about how to improve this. Maybe @lindyhopchris can give me some help, because he has a great library. |
hey! so I can see the point of what @ben221199 is suggesting - i.e. Atomic operations allows you to do bulk operations for a mixture of resources, whereas what this topic suggests is the ability to do bulk operations for a specific resource type. I.e. I suppose thinking about this as a package implementor, I'm not sure why I'd need to implement that if I'm planning to implement Atomic Operations. I.e. if I've implemented Atomic Operations, it's already possible to create multiple comments in one request, so I don't need a bulk create-comments endpoint in addition to the Atomic Operations endpoint. I have however got a question for @jelhan though.... I do get the point of view that new features should be extensions first, before being adopted by the spec. However, the problem is once your API has implemented an extension, it's exceptionally difficult to drop it in favour of changes to the spec, because removing an extension would be a breaking change from the client's perspective - particularly when you're developing an API that third-party clients are connecting to. I.e. your content negotiation can't one day change from allowing an extension to not allowing an extension, just because that extension has been incorporated into the spec. Not sure if this has been thought about? I'm guessing in the scenario where an extension/profile has been adopted by the spec, as a server implementor I just let clients keep sending that extension in the headers even though it is technically no longer an extension. |
I think it is important to clarify what incorporating an extension into the base specification itself would mean. An extension can not be incorporated into the base specification without changes. An extension must namespace members and query parameters defined by it. However the base specification itself must not use a member name or query parameter with a namespace. Incorporating an extension in the base specification would mean that the use cases supported by that extension would be supported by the base specification. The base specification might use a similar design as the extension. But it can not use the same design. This means that the extension and the new feature supported by a new version of specification could be supported in parallel.
It would be up to the implementation to decide if an when to drop support for an extension. Regardless if it may decide to drop support because of the use case is better supported by another extension or by a new version of the base specification itself. Due to content negotiation rules for extensions a server could support different extension in parallel even if they are defining the same namespace. In that case it only needs to ensure that both are not applied to the same request in parallel. |
@jelhan thanks for clarifying, that all makes sense! |
I see. Maybe if I still want this bulk feature, I should make something like |
I think that would be best way forward. Happy to review a draft of such an extension! |
I published a draft for a bulk creation extension: https://github.com/jelhan/json-api-bulk-create-extension Happy to receive feedback, questions and suggestions as issues on that GitHub repository. I decided to limit it to resource creation only.
|
Cool. This is what I meant when creating this issue, but in my case without |
Wow such a wonderful initiative, it's definitely a missing part of the existing standard, hope it will bring the schema to a new level of maturity. |
I don't see any need adding a feature to the base specification if it can be solved well using an extension or profile. I tend towards keeping the base spec lean. |
Hi Everyone, I know this has been discussed extensively, but I have two questions. 1: Why do we need to add 2: With |
Great to hear that Atlassisn is using JSON:API a lot. We can for sure consider adding bulk support to base specification at some point in time. But I'm still convinced that we should gather experience from real world usage before using extensions. What is blocking you from using an extension at Atlassian to address that common need? |
Nothing is stopping us from using the extension. It's more that there is consensus for it to be in the main spec and two for it not to need a |
At the moment, for server-to-client documents (GET) the JSONAPI content could be:
{"data":null}
(no resource){"data":{}}
(one resource){"data":[]}
(multiple resources)However, for client-to-server documents (POST, etc.) the JSON content seems to be only be:
{"data":{}}
(one resource)Section 7.1 tells:
However, I would suggest to add support for bulk creation/updating/deletion for the SAME type without using the Atom Operations extension. For this feature the JSONAPI document format does NOT have to change, because
[]
is already supported by the document parser, but only NOT added as possible value for POST requests. In this case, bulk would be possible using one request. (Eventually{"data":null}
could be supported too for POST requests if for some reason.)If there will be no errors during bulk, the server could respond with normal status code. If there will be errors, the server could choose to let all resources fail and show the errors or add the valid ones and show errors for the failing ones. In the last case, it maybe should be allowed to use
data
next toerrors
. (Maybe introduce a newerrors
attribute to tell what the server did; maybe:{"partly":true}
. (This could also be a meta thing, so that it is up to the client to handle the partly failing operation.)I also think this suggestion is compatible with previous versions because of the never remove, only add strategy. As already told, all JSONAPI parsers already support this format.
The text was updated successfully, but these errors were encountered: