@@ -117,25 +117,24 @@ public virtual async Task<object> GetRelationshipsAsync(TId id, string relations
117117
118118 public virtual async Task < object > GetRelationshipAsync ( TId id , string relationshipName )
119119 {
120- // compound-property -> CompoundProperty
121- var navigationPropertyName = _jsonApiContext . ContextGraph . GetRelationshipName < TResource > ( relationshipName ) ;
122- if ( navigationPropertyName == null )
123- throw new JsonApiException ( 422 , $ "Relationship '{ relationshipName } ' does not exist on resource '{ typeof ( TResource ) } '.") ;
124-
125- var entity = await _entities . GetAndIncludeAsync ( id , navigationPropertyName ) ;
120+ var entity = await _entities . GetAndIncludeAsync ( id , relationshipName ) ;
126121
127122 // TODO: it would be better if we could distinguish whether or not the relationship was not found,
128123 // vs the relationship not being set on the instance of T
129124 if ( entity == null )
130125 {
131- throw new JsonApiException ( 404 , $ "Relationship '{ navigationPropertyName } ' not found.") ;
126+ throw new JsonApiException ( 404 , $ "Relationship '{ relationshipName } ' not found.") ;
132127 }
133128
134129 var resource = MapOut ( entity ) ;
135130
136- var relationship = _jsonApiContext . ContextGraph . GetRelationship ( resource , navigationPropertyName ) ;
131+ // compound-property -> CompoundProperty
132+ var navigationPropertyName = _jsonApiContext . ContextGraph . GetRelationshipName < TResource > ( relationshipName ) ;
133+ if ( navigationPropertyName == null )
134+ throw new JsonApiException ( 422 , $ "Relationship '{ relationshipName } ' does not exist on resource '{ typeof ( TResource ) } '.") ;
137135
138- return relationship ;
136+ var relationshipValue = _jsonApiContext . ContextGraph . GetRelationship ( resource , navigationPropertyName ) ;
137+ return relationshipValue ;
139138 }
140139
141140 public virtual async Task < TResource > UpdateAsync ( TId id , TResource resource )
0 commit comments