@@ -12,7 +12,7 @@ namespace JsonApiDotNetCore.Builders
12
12
public class DocumentBuilder : IDocumentBuilder
13
13
{
14
14
private readonly IJsonApiContext _jsonApiContext ;
15
- private readonly IContextGraph _contextGraph ;
15
+ private readonly IResourceGraph _resourceGraph ;
16
16
private readonly IRequestMeta _requestMeta ;
17
17
private readonly DocumentBuilderOptions _documentBuilderOptions ;
18
18
private readonly IScopedServiceProvider _scopedServiceProvider ;
@@ -24,15 +24,15 @@ public DocumentBuilder(
24
24
IScopedServiceProvider scopedServiceProvider = null )
25
25
{
26
26
_jsonApiContext = jsonApiContext ;
27
- _contextGraph = jsonApiContext . ContextGraph ;
27
+ _resourceGraph = jsonApiContext . ResourceGraph ;
28
28
_requestMeta = requestMeta ;
29
29
_documentBuilderOptions = documentBuilderOptionsProvider ? . GetDocumentBuilderOptions ( ) ?? new DocumentBuilderOptions ( ) ;
30
30
_scopedServiceProvider = scopedServiceProvider ;
31
31
}
32
32
33
33
public Document Build ( IIdentifiable entity )
34
34
{
35
- var contextEntity = _contextGraph . GetContextEntity ( entity . GetType ( ) ) ;
35
+ var contextEntity = _resourceGraph . GetContextEntity ( entity . GetType ( ) ) ;
36
36
37
37
var resourceDefinition = _scopedServiceProvider ? . GetService ( contextEntity . ResourceType ) as IResourceDefinition ;
38
38
var document = new Document
@@ -52,7 +52,7 @@ public Document Build(IIdentifiable entity)
52
52
public Documents Build ( IEnumerable < IIdentifiable > entities )
53
53
{
54
54
var entityType = entities . GetElementType ( ) ;
55
- var contextEntity = _contextGraph . GetContextEntity ( entityType ) ;
55
+ var contextEntity = _resourceGraph . GetContextEntity ( entityType ) ;
56
56
var resourceDefinition = _scopedServiceProvider ? . GetService ( contextEntity . ResourceType ) as IResourceDefinition ;
57
57
58
58
var enumeratedEntities = entities as IList < IIdentifiable > ?? entities . ToList ( ) ;
@@ -179,7 +179,7 @@ private RelationshipData GetRelationshipData(RelationshipAttribute attr, Context
179
179
}
180
180
181
181
// 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 ) ;
183
183
if ( navigationEntity == null )
184
184
relationshipData . SingleData = attr . IsHasOne
185
185
? GetIndependentRelationshipIdentifier ( ( HasOneAttribute ) attr , entity )
@@ -217,7 +217,7 @@ private List<ResourceObject> IncludeRelationshipChain(
217
217
if ( relationship == null )
218
218
throw new JsonApiException ( 400 , $ "{ parentEntity . EntityName } does not contain relationship { requestedRelationship } ") ;
219
219
220
- var navigationEntity = _jsonApiContext . ContextGraph . GetRelationshipValue ( parentResource , relationship ) ;
220
+ var navigationEntity = _jsonApiContext . ResourceGraph . GetRelationshipValue ( parentResource , relationship ) ;
221
221
if ( navigationEntity is IEnumerable hasManyNavigationEntity )
222
222
{
223
223
foreach ( IIdentifiable includedEntity in hasManyNavigationEntity )
@@ -240,7 +240,7 @@ private List<ResourceObject> IncludeSingleResourceRelationships(
240
240
{
241
241
if ( relationshipChainIndex < relationshipChain . Length )
242
242
{
243
- var nextContextEntity = _jsonApiContext . ContextGraph . GetContextEntity ( relationship . Type ) ;
243
+ var nextContextEntity = _jsonApiContext . ResourceGraph . GetContextEntity ( relationship . Type ) ;
244
244
var resource = ( IIdentifiable ) navigationEntity ;
245
245
// recursive call
246
246
if ( relationshipChainIndex < relationshipChain . Length - 1 )
@@ -271,7 +271,7 @@ private ResourceObject GetIncludedEntity(IIdentifiable entity)
271
271
{
272
272
if ( entity == null ) return null ;
273
273
274
- var contextEntity = _jsonApiContext . ContextGraph . GetContextEntity ( entity . GetType ( ) ) ;
274
+ var contextEntity = _jsonApiContext . ResourceGraph . GetContextEntity ( entity . GetType ( ) ) ;
275
275
var resourceDefinition = _scopedServiceProvider . GetService ( contextEntity . ResourceType ) as IResourceDefinition ;
276
276
277
277
var data = GetData ( contextEntity , entity , resourceDefinition ) ;
@@ -296,7 +296,7 @@ private List<ResourceIdentifierObject> GetRelationships(IEnumerable<object> enti
296
296
// so, we just lookup the type of the first entity on the graph
297
297
// this is better than trying to get it from the generic parameter since it could
298
298
// 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 ;
300
300
relationships . Add ( new ResourceIdentifierObject
301
301
{
302
302
Type = typeName ,
@@ -309,7 +309,7 @@ private List<ResourceIdentifierObject> GetRelationships(IEnumerable<object> enti
309
309
private ResourceIdentifierObject GetRelationship ( object entity )
310
310
{
311
311
var objType = entity . GetType ( ) ;
312
- var contextEntity = _jsonApiContext . ContextGraph . GetContextEntity ( objType ) ;
312
+ var contextEntity = _jsonApiContext . ResourceGraph . GetContextEntity ( objType ) ;
313
313
314
314
if ( entity is IIdentifiable identifiableEntity )
315
315
return new ResourceIdentifierObject
@@ -327,7 +327,7 @@ private ResourceIdentifierObject GetIndependentRelationshipIdentifier(HasOneAttr
327
327
if ( independentRelationshipIdentifier == null )
328
328
return null ;
329
329
330
- var relatedContextEntity = _jsonApiContext . ContextGraph . GetContextEntity ( hasOne . Type ) ;
330
+ var relatedContextEntity = _jsonApiContext . ResourceGraph . GetContextEntity ( hasOne . Type ) ;
331
331
if ( relatedContextEntity == null ) // TODO: this should probably be a debug log at minimum
332
332
return null ;
333
333
0 commit comments