-
Notifications
You must be signed in to change notification settings - Fork 300
How to implement atomic operations #995
-
The new JSON:API spec has added Atomic Operations: https://jsonapi.org/ext/atomic/
This is to discuss how could this be implemented in a salable and DRY way.
Edit:
@jokiefer has started working on a library drf-json-api-atomic-operations, and we encourage anyone who needs atomic operation support to join his effort implementing it.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 6 comments 6 replies
-
thats for version 1.1 of the spec which this package do not support yet.
Beta Was this translation helpful? Give feedback.
All reactions
-
Yes, I am aware.
Eventually it should support. That's why I opened this here in discussions.
Beta Was this translation helpful? Give feedback.
All reactions
-
@SafaAlfulaij Thanks for starting this discussion. As stated those extensions are a draft and to quote from the page "describes features from an upcoming version of the of the JSON:API specification and is subject to change without notice."
This needs to be kept in mind when discussing this. My initial thought is that implementation of such a feature might actually be best done or experimented with in an external library. When matured it can still be considered to be added to this library. But even if we consider developing such a feature within DJA itself it is important that it is a separate optional feature (not like the current polymorphic support which can not easily be separated from the main of the code). This will most likely mean to improve the API of the general DJA classes. This will be more work but eventually will be a win for all DJA users as well.
Beta Was this translation helpful? Give feedback.
All reactions
-
As per the recent comment of the json-api team. the core and specs are alreasy fixed. they are now waiting for reference implementations to tweaks any edge cases. those are very minor issues. so 3rd part proof o concept extensons can be developed and pull requests created for review. since the both spec versions will be backward compatible. having a new implementation would be great before merging intro here.
Beta Was this translation helpful? Give feedback.
All reactions
-
Fair enough.
I guess that I'll experiment and see how it goes.
Some points that I'll put here for future:
- DB transaction
- Performance optimization
1. Batched creating/editing/deleting DB operations
2. Batched relationships querying (validation)
Beta Was this translation helpful? Give feedback.
All reactions
-
The new JSON:API spec has added Atomic Operations: https://jsonapi.org/ext/atomic/ This is to discuss how could this be implemented in a salable and DRY way.
also before implementing an exension, we need to implement the baseline core features of v 1.1 rc3+ :D
Beta Was this translation helpful? Give feedback.
All reactions
-
Curious where things stand on both v1.1 support (having trouble finding in the docs) and potential for atomic extension support?
Beta Was this translation helpful? Give feedback.
All reactions
-
JSON:API v1.1 is now final. Our progress in implementing it can be found in this discussion.
As atomic operation is an extension to JSON:API spec, I think it makes most sense to implement support for it in a 3rdParty library and in DJA we focus on getting the new v1.1 standard implemented. If anyone wants to pick this up and create a library, that would be great. If a library is well established, it can always be considered again to re-integrate it into DJA. See also my reply.
Beta Was this translation helpful? Give feedback.
All reactions
-
Since this is not yet available in this library I made my own sketch in Flask before implementing it myself in my Django project. Maybe it helps someone: https://github.com/Nekidev/jsonapi-atomic
Beta Was this translation helpful? Give feedback.
All reactions
-
Here is a first alpha version for an atomic operations extension. Helpfull if someone could contribute. 🙏
Beta Was this translation helpful? Give feedback.
All reactions
-
❤️ 1
-
Any update on this? Will official support be added to this project? Or should we plan on using jokiefer's extension?
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks for following up on this. As stated in my comment here we highly encourage implementing atomic operations in a 3rd party library as it is also an extension to JSON:API spec as such. Thanks @jokiefer that you started to work on this and @avelosa it would be great if you could join his effort by using and testing drf-json-api-atomic-operations. Once it is in a usable state feel free to open a PR to add the library to our list of 3rd party libraries.
I will also update the initial description of this discussion, so it is clear for people what the decision is when they stumble upon it.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1