-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add guidance for types which should not have new structural properties #537
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
55e2ef0
Create coreTypes.md
tylercleveland2 57e6d71
Update GuidelinesGraph.md
tylercleveland2 5818436
Update coreTypes.md
tylercleveland2 cc8a934
Update coreTypes.md
tylercleveland2 2ca37ff
Update GuidelinesGraph.md
tylercleveland2 6aa47c1
Update graph/articles/coreTypes.md
tylercleveland2 c9405c4
Update graph/articles/coreTypes.md
tylercleveland2 34b9192
Update graph/articles/coreTypes.md
tylercleveland2 af4e80a
Update graph/articles/coreTypes.md
tylercleveland2 f47f452
Update GuidelinesGraph.md
tylercleveland2 50ab124
Update coreTypes.md
tylercleveland2 33faa27
Update coreTypes.md
tylercleveland2 5d907fc
Update coreTypes.md
tylercleveland2 f9d8f70
Update coreTypes.md
tylercleveland2 1982472
Update coreTypes.md
tylercleveland2 59e0cd7
Update coreTypes.md
tylercleveland2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Core Types | ||
|
||
## Overview | ||
|
||
Types exist in Microsoft Graph which are highly-connected/central to the Microsoft Graph ecosystem. Often, these types are in the position of being able to contain structural properties relevant to other APIs, because they are connected to many entities in Microsoft Graph. | ||
|
||
Structural properties should be only added to these core types when they are intrinsic to the entity itself, and strictly not for the purpose of convenience due to the entity's position in Microsoft Graph. | ||
|
||
## Core Types in Microsoft Graph | ||
|
||
The following types are identified as core types, and will require strong justification to allow new structural properties to be added in all cases. | ||
|
||
- ```user``` | ||
- ```group``` | ||
- ```device``` | ||
|
||
## Alternatives to Adding Structural Properties | ||
|
||
Instead of adding a structural property to the existing core type (`user`, `group` or `device`), create a new type that models the information captured in the proposed structural property(s). | ||
Then, model the relationship between the existing core type and the new type by adding a navigation property. For information on modeling with navigation properties, see [Navigation Property](../patterns/navigation-property.md). | ||
|
||
## Example: | ||
|
||
Modeling adding "bank account information", which includes two properties `accountNumber` and `routingNumber`, to entity type ```user```. | ||
|
||
### Don't: | ||
|
||
Don't add new properties to core types such as `user`. | ||
|
||
```xml | ||
<EntityType name="user"> | ||
<Property Name="accountNumber" Type="Edm.string"/> | ||
<Property Name="routingNumber" Type="Edm.string"/> | ||
</EntityType> | ||
``` | ||
|
||
### Do: | ||
|
||
Model the information by creating a new type and model the relationship to the existing core type with a navigation property. To determine which option is most appropriate, see [Navigation Property](../patterns/navigation-property.md): | ||
|
||
#### Option 1: Add a navigation property on the existing core type to the new type, containing the new type. | ||
|
||
Define the new entity type: | ||
```xml | ||
<EntityType name="bankAccountDetail"> | ||
<Property Name="accountNumber" Type="Edm.string"/> | ||
<Property Name="routingNumber" Type="Edm.string"/> | ||
</EntityType> | ||
``` | ||
|
||
Add a contained navigation from user to the new entity type: | ||
```xml | ||
<EntityType name="user"> | ||
<NavigationProperty Name="bankAccountDetail" Type="bankAccountDetail" ContainsTarget="true"/> | ||
</EntityType> | ||
``` | ||
|
||
#### Option 2: Contain the new type in an entity set elsewhere, and add a navigation property to the new type on the existing core type. | ||
|
||
Define the new entity type: | ||
```xml | ||
<EntityType name="bankAccountDetail"> | ||
<Property Name="accountNumber" Type="Edm.string"/> | ||
<Property Name="routingNumber" Type="Edm.string"/> | ||
</EntityType> | ||
``` | ||
|
||
Contain the new entity type in an entity set or singleton: | ||
```xml | ||
<EntitySet Name="bankAccountDetails" EntityType="bankAccountDetail"> | ||
``` | ||
|
||
Add a navigation from user to the new type: | ||
```xml | ||
<EntityType name="user"> | ||
<NavigationProperty Name="bankAccountDetail" Type="bankAccountDetail" /> | ||
</EntityType> | ||
``` | ||
|
||
#### Option 3: Contain the new type in an entity set elsewhere, and add a navigation property to the existing core type on the new type. | ||
|
||
Define the new entity type, with a navigation to the user: | ||
```xml | ||
<EntityType name="bankAccountDetail"> | ||
<Property Name="accountNumber" Type="Edm.string"/> | ||
<Property Name="routingNumber" Type="Edm.string"/> | ||
<NavigationProperty Name="user" Type="microsoft.graph.user" /> | ||
</EntityType> | ||
``` | ||
|
||
Contain the new entity type in an entity set or singleton: | ||
```xml | ||
<EntitySet Name="bankAccountInformations" EntityType="bankAccountInformation"> | ||
``` |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add this guidance for applications and servicePrincipals too? In my mind those are core types.
We actually now have a very real example of why this is important for downstream tooling. Adding a structural property that is handled by a different workload (from the core workload) is really difficult to model with Bicep. If instead it's added as a new entity + nav property, this fits cleanly with Bicep (and ARM's) nested child resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I think we have a different ADR that says we should stop using composite entities.
I'm ok adding
applications
andservicePrincipals
, but I don't think those have been brought up with the API council. Do we want to take this PR as-is and do a follow-up to add apps and sps after discussion with the council?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am inclined to take Garrett's suggestion. If you are fine with this, I will merge as-is @dkershaw10