Skip to content

Commit 7a17ba8

Browse files
committed
Updated based on comments
1 parent 90ba65e commit 7a17ba8

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

graph/patterns/navigation-property.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@ Microsoft Graph API Design Pattern
99

1010
It is often valuable to represent a relationship between resources in an API. This may be a many-to-one or a one-to-many relationship.
1111

12-
Relationships between resources are often implicitly represented by a property contained in one of the resources that identifies the other related resource. Usually that information returned in a representation as an id value and the property is named using a convention that identifies the target type of related resource. e.g. userId
12+
Relationships between resources are often implicitly represented by a property contained in one of the resources that provides a key to a related resource. Usually that information is returned in a representation as an id value and the property is named using a convention that identifies the target type of related resource. e.g. userId
1313

14-
In many-to-one relationships, for a client to access the related resource it must request the primary resource, read the id value of the related resource and then construct a URL to the related resource using the Id value and knowledge of how the property name maps to the related resource. This requires at least two round trips and requires the client know how to construct the URL to the related resource.
15-
16-
For both many-to-one and one-to-many relationships in order to retrieve information from both resources on both sides of the relationship requires at minimum two requests.
17-
18-
Requiring two round trips to access this information is inefficient for some applications and the lack of a formally described relationship limits the ability for tooling to take advantage of the relationship to improve developer experience.
14+
The use of foreign key properties to describe related resources is a weakly typed mechanism and requires additional information for a developer to traverse the relationship. Discovery of related resources is not trivial.
1915

2016
## Solution
2117
--------
@@ -32,7 +28,7 @@ Additionally, using the OData Expand query parameter, related entities can be tr
3228

3329
In the current Microsoft Graph implementation, support for navigation properties is limited to entities within the same backend service or the user entity.
3430

35-
Navigation properties defined within an entity are not returned when retreiving the representation of an entity.
31+
Navigation properties defined within an entity are not returned when retreiving the representation of an entity unless explicity desired by a service.
3632

3733
Implementing support for accessing the "$ref" of a navigation property allows a caller to return just the URL of related resource. e.g. `/user/23/manager/$ref`. This is useful when a client wishes to identity the related resource but doesn't need all of its properties.
3834

@@ -51,6 +47,8 @@ Resources that contain a parent Id property in a child resource can utilize a na
5147

5248
`/invoice/{invoiceId}/items/{itemId}?expand=parentInvoice(select=invoiceDate,Customer)`
5349

50+
### "child-parent" relationships
51+
5452
One other use case is when child resources appear in a non-contained collection and there is a desire to access the canonical parent:
5553

5654
`/me/pinnedChannels/{channelId}/team`
@@ -73,6 +71,13 @@ Content-Type: application/json
7371
}
7472
```
7573

74+
This navigation property could be described with the following CSDL:
75+
```xml
76+
<EntityType Name="user">
77+
<NavigationProperty Name="manager" Type="user" ContainsTarget="false" >
78+
</EntityType>
79+
```
80+
7681
### Retrieving a reference to a related entity
7782

7883
```http

0 commit comments

Comments
 (0)