Skip to content

Various fixes and improvements #1114

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

Merged
merged 29 commits into from
Nov 22, 2021
Merged

Various fixes and improvements #1114

merged 29 commits into from
Nov 22, 2021

Conversation

bart-degreed
Copy link
Contributor

Various fixes and improvements that I wrote down over the last few weeks while working on other things. See the individual commits for details.

Fixes #1110 and #1106.

QUALITY CHECKLIST

  • Changes implemented in code
  • Complies with our contributing guidelines
  • Adapted tests
  • Documentation updated
  • N/A: Created issue to update Templates: {ISSUE_NUMBER}

Bart Koelman added 17 commits November 18, 2021 15:38
…base on POST many-to-many and DELETE to-many requests
…g null for missing services

This produces HTTP 405 (Method Not Allowed) instead of 404 (Not Found), which better reveals the intent
…pe parameter, used for non-generic or generic constructed interfaces
Apparently EF Core 5 did not always fail on missing required relationships, which was fixed in EF Core 6. I tried to update existing tests leaving the models intact, but that poluted lots of tests so I made them optional instead.
…pReadOnly, NoHttpPost etc. because they interfere with relationship endpoints. For example, blocking POST would block creating resources, as well as adding to to-many relationships, which is not very useful. The replacement is to inject just the subset of exposed services, or simply use the Command/Query controllers. When an endpoint is not exposed, we now return HTTP 403 Forbidden instead of 404 or 405.
@codecov
Copy link

codecov bot commented Nov 19, 2021

Codecov Report

Merging #1114 (622fddc) into master (8a6bfac) will increase coverage by 0.40%.
The diff coverage is 95.41%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1114      +/-   ##
==========================================
+ Coverage   88.60%   89.00%   +0.40%     
==========================================
  Files         255      249       -6     
  Lines        7160     7123      -37     
==========================================
- Hits         6344     6340       -4     
+ Misses        816      783      -33     
Impacted Files Coverage Δ
src/Examples/JsonApiDotNetCoreExample/Startup.cs 0.00% <0.00%> (ø)
...iDotNetCore/Middleware/JsonApiRoutingConvention.cs 90.47% <0.00%> (ø)
...nApiDotNetCore/Resources/IdentifiableExtensions.cs 54.54% <33.33%> (ø)
...e/Serialization/Response/ResourceObjectTreeNode.cs 75.26% <85.71%> (ø)
...ApiDotNetCore/Errors/RouteNotAvailableException.cs 87.50% <87.50%> (ø)
src/Examples/NoEntityFrameworkExample/Startup.cs 100.00% <100.00%> (ø)
...onApiDotNetCore/AtomicOperations/LocalIdTracker.cs 97.50% <100.00%> (ø)
...ApiDotNetCore/AtomicOperations/LocalIdValidator.cs 100.00% <100.00%> (ø)
...DotNetCore/AtomicOperations/OperationsProcessor.cs 96.87% <100.00%> (ø)
...ore/AtomicOperations/Processors/CreateProcessor.cs 100.00% <100.00%> (ø)
... and 28 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8a6bfac...622fddc. Read the comment docs.

@bart-degreed bart-degreed force-pushed the various branch 2 times, most recently from e36e8ca to 2ef4daf Compare November 19, 2021 14:01
Bart Koelman added 8 commits November 19, 2021 15:31
…llows for more intelligence in the link builder, such as handling versioning or inheritance.
…lls back to it on failure. This produces more correct error responses in operations, compared to rolling back the entire transaction. For example, when an operations request creates a resource and the next operation fails, the resource service may incorrectly conclude that the resource from the first operation does not exist.
@bart-degreed bart-degreed marked this pull request as ready for review November 20, 2021 21:58
@bart-degreed bart-degreed requested a review from maurei November 20, 2021 21:58
@bart-degreed bart-degreed merged commit ae17e01 into master Nov 22, 2021
@bart-degreed bart-degreed deleted the various branch November 22, 2021 11:10
bart-degreed pushed a commit that referenced this pull request Dec 3, 2021
* Fixed inconsistencies in naming of resource type

* Fixed: Query to determine initial state is sent to the read-only database on POST many-to-many and DELETE to-many requests

* Make command/query controllers inherit from JsonApiController, passing null for missing services
This produces HTTP 405 (Method Not Allowed) instead of 404 (Not Found), which better reveals the intent

* Added overload on TypeExtensions.IsOrImplementsInterface to take a type parameter, used for non-generic or generic constructed interfaces

* Use ResourceType instead of public name in local-id tracker

* Change IQueryStringParameterReader.AllowEmptyValue into normal interface member

* Simplified startup in example project

* Removed left-over overload with single type parameter in ResourceGraphBuilder

* Various corrections in documentation, added #nullable where it makes a difference

* Revert DocFx workaround

* Updated version compatibility table

* Added release notes and icon to NuGet package

* Fix nullability warnings produced by .NET 6 with EF Core 6

* Fixed: Error when using EagerLoad on a relationship

* Use VS2022 image in AppVeyor on Windows

* Fixed broken tests on EF Core 6
Apparently EF Core 5 did not always fail on missing required relationships, which was fixed in EF Core 6. I tried to update existing tests leaving the models intact, but that poluted lots of tests so I made them optional instead.

* Fixed redacted data when running tests

* Breaking: Removed access-control action filter attributes such as HttpReadOnly, NoHttpPost etc. because they interfere with relationship endpoints. For example, blocking POST would block creating resources, as well as adding to to-many relationships, which is not very useful. The replacement is to inject just the subset of exposed services, or simply use the Command/Query controllers. When an endpoint is not exposed, we now return HTTP 403 Forbidden instead of 404 or 405.

* Increase version number, use branch name in suffix

* Pass the full resource to LinkBuilder, instead of just its ID. This allows for more intelligence in the link builder, such as handling versioning or inheritance.

* Optimization: Only save when there are changes in a remove-from-to-many relationship request

* Clarifications in doc-comments

* Extract constant

* Extract method

* Cleanup SelectClauseBuilder.ToPropertySelectors

* Since EF Core 5, SaveChanges automatically creates a savepoint and rolls back to it on failure. This produces more correct error responses in operations, compared to rolling back the entire transaction. For example, when an operations request creates a resource and the next operation fails, the resource service may incorrectly conclude that the resource from the first operation does not exist.

* Improved unittests for populating IJsonApiRequest in middleware

* Clarify intent in AtomicOperationObjectAdapter

* Review feedback: use `ResourceType resourceType` instead of `ResourceType type` everywhere
bart-degreed pushed a commit that referenced this pull request Dec 3, 2021
* Fixed inconsistencies in naming of resource type

* Fixed: Query to determine initial state is sent to the read-only database on POST many-to-many and DELETE to-many requests

* Make command/query controllers inherit from JsonApiController, passing null for missing services
This produces HTTP 405 (Method Not Allowed) instead of 404 (Not Found), which better reveals the intent

* Added overload on TypeExtensions.IsOrImplementsInterface to take a type parameter, used for non-generic or generic constructed interfaces

* Use ResourceType instead of public name in local-id tracker

* Change IQueryStringParameterReader.AllowEmptyValue into normal interface member

* Simplified startup in example project

* Removed left-over overload with single type parameter in ResourceGraphBuilder

* Various corrections in documentation, added #nullable where it makes a difference

* Revert DocFx workaround

* Updated version compatibility table

* Added release notes and icon to NuGet package

* Fix nullability warnings produced by .NET 6 with EF Core 6

* Fixed: Error when using EagerLoad on a relationship

* Use VS2022 image in AppVeyor on Windows

* Fixed broken tests on EF Core 6
Apparently EF Core 5 did not always fail on missing required relationships, which was fixed in EF Core 6. I tried to update existing tests leaving the models intact, but that poluted lots of tests so I made them optional instead.

* Fixed redacted data when running tests

* Breaking: Removed access-control action filter attributes such as HttpReadOnly, NoHttpPost etc. because they interfere with relationship endpoints. For example, blocking POST would block creating resources, as well as adding to to-many relationships, which is not very useful. The replacement is to inject just the subset of exposed services, or simply use the Command/Query controllers. When an endpoint is not exposed, we now return HTTP 403 Forbidden instead of 404 or 405.

* Increase version number, use branch name in suffix

* Pass the full resource to LinkBuilder, instead of just its ID. This allows for more intelligence in the link builder, such as handling versioning or inheritance.

* Optimization: Only save when there are changes in a remove-from-to-many relationship request

* Clarifications in doc-comments

* Extract constant

* Extract method

* Cleanup SelectClauseBuilder.ToPropertySelectors

* Since EF Core 5, SaveChanges automatically creates a savepoint and rolls back to it on failure. This produces more correct error responses in operations, compared to rolling back the entire transaction. For example, when an operations request creates a resource and the next operation fails, the resource service may incorrectly conclude that the resource from the first operation does not exist.

* Improved unittests for populating IJsonApiRequest in middleware

* Clarify intent in AtomicOperationObjectAdapter

* Review feedback: use `ResourceType resourceType` instead of `ResourceType type` everywhere
bart-degreed pushed a commit that referenced this pull request Dec 3, 2021
* Fixed inconsistencies in naming of resource type

* Fixed: Query to determine initial state is sent to the read-only database on POST many-to-many and DELETE to-many requests

* Make command/query controllers inherit from JsonApiController, passing null for missing services
This produces HTTP 405 (Method Not Allowed) instead of 404 (Not Found), which better reveals the intent

* Added overload on TypeExtensions.IsOrImplementsInterface to take a type parameter, used for non-generic or generic constructed interfaces

* Use ResourceType instead of public name in local-id tracker

* Change IQueryStringParameterReader.AllowEmptyValue into normal interface member

* Simplified startup in example project

* Removed left-over overload with single type parameter in ResourceGraphBuilder

* Various corrections in documentation, added #nullable where it makes a difference

* Revert DocFx workaround

* Updated version compatibility table

* Added release notes and icon to NuGet package

* Fix nullability warnings produced by .NET 6 with EF Core 6

* Fixed: Error when using EagerLoad on a relationship

* Use VS2022 image in AppVeyor on Windows

* Fixed broken tests on EF Core 6
Apparently EF Core 5 did not always fail on missing required relationships, which was fixed in EF Core 6. I tried to update existing tests leaving the models intact, but that poluted lots of tests so I made them optional instead.

* Fixed redacted data when running tests

* Breaking: Removed access-control action filter attributes such as HttpReadOnly, NoHttpPost etc. because they interfere with relationship endpoints. For example, blocking POST would block creating resources, as well as adding to to-many relationships, which is not very useful. The replacement is to inject just the subset of exposed services, or simply use the Command/Query controllers. When an endpoint is not exposed, we now return HTTP 403 Forbidden instead of 404 or 405.

* Increase version number, use branch name in suffix

* Pass the full resource to LinkBuilder, instead of just its ID. This allows for more intelligence in the link builder, such as handling versioning or inheritance.

* Optimization: Only save when there are changes in a remove-from-to-many relationship request

* Clarifications in doc-comments

* Extract constant

* Extract method

* Cleanup SelectClauseBuilder.ToPropertySelectors

* Since EF Core 5, SaveChanges automatically creates a savepoint and rolls back to it on failure. This produces more correct error responses in operations, compared to rolling back the entire transaction. For example, when an operations request creates a resource and the next operation fails, the resource service may incorrectly conclude that the resource from the first operation does not exist.

* Improved unittests for populating IJsonApiRequest in middleware

* Clarify intent in AtomicOperationObjectAdapter

* Review feedback: use `ResourceType resourceType` instead of `ResourceType type` everywhere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Relationship update request may query read-only replica
2 participants