fix(data): make non-optimistic add command entity partial#3859
Merged
brandonroberts merged 1 commit intongrx:masterfrom Apr 29, 2023
Nosfistis:bugfix/data/entity-commands-add-type
Merged
fix(data): make non-optimistic add command entity partial#3859brandonroberts merged 1 commit intongrx:masterfrom Nosfistis:bugfix/data/entity-commands-add-type
brandonroberts merged 1 commit intongrx:masterfrom
Nosfistis:bugfix/data/entity-commands-add-type
Conversation
✅ Deploy Preview for ngrx-io canceled.Built without sensitive environment variables
|
| */ | ||
| add( | ||
| entity: Partial<T>, | ||
| options: EntityActionOptions & { isOptimistic: false } |
Member
There was a problem hiding this comment.
Could you also add a test that verifies this functionality please?
Contributor
Author
There was a problem hiding this comment.
Given that this is just a type change, I found it not necessary. I will add a test that would cause Typescript to fail build if it does not work.
Contributor
Author
|
Digging a little deeper in the dispatcher I found out that the default behavior is indeed pessimistic. However, the initial PR types have been reverted, and omitting the options argument causes a non-partial entity argument (optimistic-like). I suggest using add(
entity: Partial<T>,
options?: EntityActionOptions & { isOptimistic?: false }
): Observable<T>;
add(
entity: T,
options: EntityActionOptions & { isOptimistic: true }
): Observable<T>;
add(entity: T, options?: EntityActionOptions): Observable<T>;which seems to cover all cases without fail. |
Mirror the type definition of EntityCollectionServiceBase.add on EntityServerCommands.add. Closes EntityServerCommands.add does not allow optional id #3847
brandonroberts
approved these changes
Apr 29, 2023
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.
Mirror the type definition of EntityCollectionServiceBase.add on EntityServerCommands.add.
Closes EntityServerCommands.add does not allow optional id #3847
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
EntityServerCommands.add()allows only full entities.Closes #3847
What is the new behavior?
EntityServerCommands.add()allows partial entities if non-optimistic, just likeEntityCollectionServiceBase.add().Does this PR introduce a breaking change?