implement AllowClientUUIDs for record creation#241
Open
bartke wants to merge 1 commit intoariga:mainfrom
Open
Conversation
Author
|
@masseelch I think you might be the right person to prod here. A corresponding PR was merged in ent/contrib/entoas recently, would love to hear your feedback on this and if this is possible. |
masseelch
reviewed
Oct 26, 2023
Comment on lines
+26
to
+28
| "allowClientUUIDs": func() bool { | ||
| return cfg.AllowClientUUIDs | ||
| }, |
Member
There was a problem hiding this comment.
Instead of this I prefer to use extend and add the flag there. Have a look at how it is done inside Ent: https://github.com/ent/ent/blob/3f1063c77ec98d1b1d5d1cdc39659cd13931ab8f/entc/gen/func.go#L265
| Views map[string]*entoas.View | ||
| // Whether to allow the client to supply IDs in case uuids are used. | ||
| // AllowClientUUIDs, when enabled, allows the built-in "id" field as part of the payload for create, allowing the client to supply UUIDs as primary keys and for idempotency. | ||
| AllowClientUUIDs bool |
Member
There was a problem hiding this comment.
What about making it more generic and allow to set any ID field, if given?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a new configuration option AllowClientUUIDs. When this option is enabled, we can use a UUID supplied in the request payload as the primary key for the record, providing it's not nil. This addition supports client-supplied UUIDs, enabling idempotency in entity creation. It could be more lenient and allow strings alongside uuids too to address #107. Not sure if there is appetite for either.