@@ -12,7 +12,7 @@ namespace JsonApiDotNetCore.Builders
1212 public class DocumentBuilder : IDocumentBuilder
1313 {
1414 private readonly IJsonApiContext _jsonApiContext ;
15- private readonly IContextGraph _contextGraph ;
15+ private readonly IResourceGraph _resourceGraph ;
1616 private readonly IRequestMeta _requestMeta ;
1717 private readonly DocumentBuilderOptions _documentBuilderOptions ;
1818 private readonly IScopedServiceProvider _scopedServiceProvider ;
@@ -24,15 +24,15 @@ public DocumentBuilder(
2424 IScopedServiceProvider scopedServiceProvider = null )
2525 {
2626 _jsonApiContext = jsonApiContext ;
27- _contextGraph = jsonApiContext . ContextGraph ;
27+ _resourceGraph = jsonApiContext . ResourceGraph ;
2828 _requestMeta = requestMeta ;
2929 _documentBuilderOptions = documentBuilderOptionsProvider ? . GetDocumentBuilderOptions ( ) ?? new DocumentBuilderOptions ( ) ;
3030 _scopedServiceProvider = scopedServiceProvider ;
3131 }
3232
3333 public Document Build ( IIdentifiable entity )
3434 {
35- var contextEntity = _contextGraph . GetContextEntity ( entity . GetType ( ) ) ;
35+ var contextEntity = _resourceGraph . GetContextEntity ( entity . GetType ( ) ) ;
3636
3737 var resourceDefinition = _scopedServiceProvider ? . GetService ( contextEntity . ResourceType ) as IResourceDefinition ;
3838 var document = new Document
@@ -52,7 +52,7 @@ public Document Build(IIdentifiable entity)
5252 public Documents Build ( IEnumerable < IIdentifiable > entities )
5353 {
5454 var entityType = entities . GetElementType ( ) ;
55- var contextEntity = _contextGraph . GetContextEntity ( entityType ) ;
55+ var contextEntity = _resourceGraph . GetContextEntity ( entityType ) ;
5656 var resourceDefinition = _scopedServiceProvider ? . GetService ( contextEntity . ResourceType ) as IResourceDefinition ;
5757
5858 var enumeratedEntities = entities as IList < IIdentifiable > ?? entities . ToList ( ) ;
@@ -179,7 +179,7 @@ private RelationshipData GetRelationshipData(RelationshipAttribute attr, Context
179179 }
180180
181181 // this only includes the navigation property, we need to actually check the navigation property Id
182- var navigationEntity = _jsonApiContext . ContextGraph . GetRelationshipValue ( entity , attr ) ;
182+ var navigationEntity = _jsonApiContext . ResourceGraph . GetRelationshipValue ( entity , attr ) ;
183183 if ( navigationEntity == null )
184184 relationshipData . SingleData = attr . IsHasOne
185185 ? GetIndependentRelationshipIdentifier ( ( HasOneAttribute ) attr , entity )
@@ -217,7 +217,7 @@ private List<ResourceObject> IncludeRelationshipChain(
217217 if ( relationship == null )
218218 throw new JsonApiException ( 400 , $ "{ parentEntity . EntityName } does not contain relationship { requestedRelationship } ") ;
219219
220- var navigationEntity = _jsonApiContext . ContextGraph . GetRelationshipValue ( parentResource , relationship ) ;
220+ var navigationEntity = _jsonApiContext . ResourceGraph . GetRelationshipValue ( parentResource , relationship ) ;
221221 if ( navigationEntity is IEnumerable hasManyNavigationEntity )
222222 {
223223 foreach ( IIdentifiable includedEntity in hasManyNavigationEntity )
@@ -240,7 +240,7 @@ private List<ResourceObject> IncludeSingleResourceRelationships(
240240 {
241241 if ( relationshipChainIndex < relationshipChain . Length )
242242 {
243- var nextContextEntity = _jsonApiContext . ContextGraph . GetContextEntity ( relationship . Type ) ;
243+ var nextContextEntity = _jsonApiContext . ResourceGraph . GetContextEntity ( relationship . Type ) ;
244244 var resource = ( IIdentifiable ) navigationEntity ;
245245 // recursive call
246246 if ( relationshipChainIndex < relationshipChain . Length - 1 )
@@ -271,7 +271,7 @@ private ResourceObject GetIncludedEntity(IIdentifiable entity)
271271 {
272272 if ( entity == null ) return null ;
273273
274- var contextEntity = _jsonApiContext . ContextGraph . GetContextEntity ( entity . GetType ( ) ) ;
274+ var contextEntity = _jsonApiContext . ResourceGraph . GetContextEntity ( entity . GetType ( ) ) ;
275275 var resourceDefinition = _scopedServiceProvider . GetService ( contextEntity . ResourceType ) as IResourceDefinition ;
276276
277277 var data = GetData ( contextEntity , entity , resourceDefinition ) ;
@@ -296,7 +296,7 @@ private List<ResourceIdentifierObject> GetRelationships(IEnumerable<object> enti
296296 // so, we just lookup the type of the first entity on the graph
297297 // this is better than trying to get it from the generic parameter since it could
298298 // be less specific than what is registered on the graph (e.g. IEnumerable<object>)
299- typeName = typeName ?? _jsonApiContext . ContextGraph . GetContextEntity ( entity . GetType ( ) ) . EntityName ;
299+ typeName = typeName ?? _jsonApiContext . ResourceGraph . GetContextEntity ( entity . GetType ( ) ) . EntityName ;
300300 relationships . Add ( new ResourceIdentifierObject
301301 {
302302 Type = typeName ,
@@ -309,7 +309,7 @@ private List<ResourceIdentifierObject> GetRelationships(IEnumerable<object> enti
309309 private ResourceIdentifierObject GetRelationship ( object entity )
310310 {
311311 var objType = entity . GetType ( ) ;
312- var contextEntity = _jsonApiContext . ContextGraph . GetContextEntity ( objType ) ;
312+ var contextEntity = _jsonApiContext . ResourceGraph . GetContextEntity ( objType ) ;
313313
314314 if ( entity is IIdentifiable identifiableEntity )
315315 return new ResourceIdentifierObject
@@ -327,7 +327,7 @@ private ResourceIdentifierObject GetIndependentRelationshipIdentifier(HasOneAttr
327327 if ( independentRelationshipIdentifier == null )
328328 return null ;
329329
330- var relatedContextEntity = _jsonApiContext . ContextGraph . GetContextEntity ( hasOne . Type ) ;
330+ var relatedContextEntity = _jsonApiContext . ResourceGraph . GetContextEntity ( hasOne . Type ) ;
331331 if ( relatedContextEntity == null ) // TODO: this should probably be a debug log at minimum
332332 return null ;
333333
0 commit comments