|
2 | 2 |
|
3 | 3 | Microsoft Graph API Design Pattern
|
4 | 4 |
|
5 |
| -*A frequent pattern in Microsoft Graph is to have a small type hierarchy, a base type with a few subtypes. This lets us model collections of objects that have slightly different metadata and behavior.* |
| 5 | +*A frequent pattern in Microsoft Graph is to have a small type hierarchy, a base type with a few subtypes. This lets us model collections of resources that have slightly different metadata and behavior.* |
6 | 6 |
|
7 | 7 | ## Problem
|
8 | 8 |
|
9 |
| -The API design requires that we model a set of entities based on a common concept |
| 9 | +The API design requires that we model a set of resources based on a common concept |
10 | 10 | that can be further grouped into *mutually exclusive variants* with specific
|
11 | 11 | properties and behaviors. The API design should be evolvable and allow the addition
|
12 | 12 | of new variants without breaking changes.
|
13 | 13 |
|
14 | 14 | ## Solution
|
15 | 15 |
|
16 |
| -API designers can use OData *type hierarchy*, where there is one abstract base |
17 |
| -type with a few shared properties representing the common concept and one |
18 |
| -subtype for each variant of the entity. In the hierarchy, the interdependencies of properties, that is, which properties are relevant for which variants, is fully captured in metadata, and client code can potentially leverage that to construct and/or validate requests. |
| 16 | +API designers might use a *type hierarchy*, where there is one base |
| 17 | +type (which might be abstract) with a few shared properties representing the common concept and one |
| 18 | +subtype for each variant of the resource. In the hierarchy, the interdependencies of properties, that is, which properties are relevant for which variants, is fully captured in the type system. |
19 | 19 |
|
20 | 20 | ## When to use this pattern
|
21 | 21 |
|
22 |
| -The type hierarchy pattern is well suited to a use case where each variant of a |
23 |
| -common concept has unique properties and behaviors, no combination of variants |
24 |
| -is anticipated, and API queries are managed programmatically with type casting. |
| 22 | +Use this pattern where each variant of a common concept has its own unique properties and behaviors, |
| 23 | +no combination of variants is anticipated, |
| 24 | +and it is acceptable that callers who need to query resources by variant are adequately served by filtering or partitioning using type casting. |
25 | 25 |
|
26 |
| -You can consider related patterns such as |
27 |
| -[Facets](https://github.com/microsoft/api-guidelines/tree/graph/graph) and [Flat bag of properties](https://github.com/microsoft/api-guidelines/tree/graph/graph). |
| 26 | +Related patterns are |
| 27 | +[Facets](facets.md) and |
| 28 | +[Flat bag of properties](flatbag.md). |
28 | 29 |
|
29 | 30 | ## Issues and considerations
|
30 | 31 |
|
@@ -131,4 +132,4 @@ POST https://graph.microsoft.com/v1.0/directoryObjects
|
131 | 132 | "mailNickname": "library",
|
132 | 133 | "securityEnabled": true
|
133 | 134 | }
|
134 |
| -``` |
| 135 | +``` |
0 commit comments