Skip to content

Resource Graph validations #1101

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 3 commits into from
Nov 8, 2021
Merged

Resource Graph validations #1101

merged 3 commits into from
Nov 8, 2021

Conversation

bart-degreed
Copy link
Contributor

@bart-degreed bart-degreed commented Nov 5, 2021

The following fails at startup with InvalidConfigurationException:

  • NEW: Two resources with the same public name in the resource graph
  • NEW: Resource contains attributes/relationships with the same public name
  • NEW: Resource implements IIdentifiable, but not IIdentifiable<TId>
  • NEW: Relationship in resource points to a resource type that is not in the resource graph
  • NEW: Found JSON:API controller that uses a resource type that is not in the resource graph
  • Found multiple JSON:API controllers that use the same resource type
  • services.AddResourceService/AddResourceRepository/AddResourceDefinition is called with a type that does not implement any of the JsonApiDotNetCore interfaces

The following logs a warning at startup:

  • Resource that does not implement IIdentifiable is skipped during discovery or while adding from DbContext.
  • NEW: Resource contains no attributes
  • NEW: Empty resource graph

Fixes #170.

QUALITY CHECKLIST

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

@codecov
Copy link

codecov bot commented Nov 5, 2021

Codecov Report

Merging #1101 (22a0a09) into master (b88d39e) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1101      +/-   ##
==========================================
+ Coverage   88.59%   88.60%   +0.01%     
==========================================
  Files         255      255              
  Lines        7127     7160      +33     
==========================================
+ Hits         6314     6344      +30     
- Misses        813      816       +3     
Impacted Files Coverage Δ
...piDotNetCore/Configuration/ResourceGraphBuilder.cs 98.44% <100.00%> (+0.49%) ⬆️
...iDotNetCore/Middleware/JsonApiRoutingConvention.cs 90.47% <100.00%> (+0.31%) ⬆️
...c/JsonApiDotNetCore/Configuration/ResourceGraph.cs 75.00% <0.00%> (-5.00%) ⬇️

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 b88d39e...22a0a09. Read the comment docs.

@bart-degreed bart-degreed requested a review from maurei November 6, 2021 11:02
@bart-degreed bart-degreed marked this pull request as ready for review November 6, 2021 11:02
@maurei maurei merged commit 78a4e9d into master Nov 8, 2021
@maurei maurei deleted the graph-validations branch November 8, 2021 13:41
bart-degreed pushed a commit that referenced this pull request Dec 3, 2021
* Added extra validations of the resource graph and unified unit tests

* Fail at startup on controller that derives from BaseJsonApiController, but uses a resource type that is not registered in the resource graph

* Check off roadmap entry
bart-degreed pushed a commit that referenced this pull request Dec 3, 2021
* Added extra validations of the resource graph and unified unit tests

* Fail at startup on controller that derives from BaseJsonApiController, but uses a resource type that is not registered in the resource graph

* Check off roadmap entry
bart-degreed pushed a commit that referenced this pull request Dec 3, 2021
* Added extra validations of the resource graph and unified unit tests

* Fail at startup on controller that derives from BaseJsonApiController, but uses a resource type that is not registered in the resource graph

* Check off roadmap entry
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.

Static Validations of the ContextGraph
2 participants