in src/Epam.GraphQL/Configuration/Implementations/Relations/Relation.cs [140:196]
public IDataLoaderResult<bool> CanViewParentAsync(GraphQLContext<TExecutionContext> context, TChildEntity entity)
{
if (_relationType == RelationType.Aggregation)
{
if (ChildNavigationPropertyGetter != null)
{
var profiler = context.Profiler;
using (profiler.Step($"CanViewParentAsync:{typeof(TChildEntity).HumanizedName()}"))
{
var parent = ChildNavigationPropertyGetter(entity);
if (parent != null)
{
return _securityCheckLoader!.CanViewAsync(context, parent);
}
}
}
var prop = ChildPropertyGetter(entity);
if (prop == null)
{
return new DataLoaderResult<bool>(true);
}
if (IsPropertyId)
{
var batcher = context.Batcher;
var profiler = context.Profiler;
if (typeof(TProperty).IsAssignableFrom(typeof(TChildProperty)))
{
var castedParentLoader = _securityCheckLoader as IdentifiableLoader<TEntity, TProperty, TExecutionContext>;
var factory = BatchHelpers.GetLoaderQueryFactory<TEntityLoader, TEntity, TProperty, TExecutionContext>(
() => $"CanViewParentAsync:{typeof(TChildEntity).HumanizedName()}",
_securityCheckLoader!,
castedParentLoader!.IdExpression);
return factory(profiler, context.QueryExecuter, null, context.ExecutionContext) // TBD hooksExecuter == null here
.Then(r => r.SafeNull().Any())
.LoadAsync((TProperty)Convert.ChangeType(prop, typeof(TChildProperty), CultureInfo.InvariantCulture));
}
else if (typeof(TChildProperty).IsAssignableFrom(typeof(TProperty)))
{
var castedParentLoader = _securityCheckLoader as IdentifiableLoader<TEntity, TProperty, TExecutionContext>;
var factory = BatchHelpers.GetLoaderQueryFactory<TEntityLoader, TEntity, TProperty, TExecutionContext>(
() => $"CanViewParentAsync:{typeof(TChildEntity).HumanizedName()}",
_securityCheckLoader!,
castedParentLoader!.IdExpression);
return factory(profiler, context.QueryExecuter, null, context.ExecutionContext) // TBD hooksExecuter == null here
.Then(r => r.SafeNull().Any())
.LoadAsync((TProperty)Convert.ChangeType(prop, typeof(TProperty), CultureInfo.InvariantCulture));
}
}
}
return new DataLoaderResult<bool>(true);
}