in src/Epam.GraphQL/Configuration/Implementations/BaseObjectGraphTypeConfigurator.cs [1040:1082]
private IField<TExecutionContext> AddField(PropertyInfo propertyInfo)
{
if (propertyInfo.PropertyType != typeof(string) && propertyInfo.PropertyType.IsEnumerableType())
{
_addEnumerableFieldMethodInfo ??= ReflectionHelpers.GetMethodInfo<Func<IChainConfigurationContextOwner, IChainConfigurationContext>, string, Expression<Func<TEntity, IEnumerable<object>>>, string?, ExpressionField<TEntity, IEnumerable<object>, TExecutionContext>>(
AddField<object>);
var itemPropertyType = TypeExtensions.GetEnumerableElementType(propertyInfo.PropertyType);
var enumerablePropertyType = typeof(IEnumerable<>).MakeGenericType(itemPropertyType);
var enumerableExpression = propertyInfo.MakePropertyLambdaExpression(enumerablePropertyType);
Func<IChainConfigurationContextOwner, IChainConfigurationContext> enumerableConfigurationContextFactory = owner =>
ConfigurationContext.Chain(owner, nameof(Field))
.Argument(propertyInfo.Name)
.Argument(enumerableExpression);
return _addEnumerableFieldMethodInfo.MakeGenericMethod(itemPropertyType).InvokeAndHoistBaseException<IField<TExecutionContext>>(
this,
enumerableConfigurationContextFactory,
propertyInfo.Name,
enumerableExpression,
null);
}
_addFieldMethodInfo ??= ReflectionHelpers.GetMethodInfo<Func<IChainConfigurationContextOwner, IChainConfigurationContext>, string, Expression<Func<TEntity, object>>, string?, ExpressionField<TEntity, object, TExecutionContext>>(
AddField<object>);
var propertyType = propertyInfo.PropertyType;
var expressionType = typeof(Expression<>).MakeGenericType(typeof(Func<,>).MakeGenericType(typeof(TEntity), propertyType));
var expression = propertyInfo.MakePropertyLambdaExpression();
Func<IChainConfigurationContextOwner, IChainConfigurationContext> configurationContextFactory = owner =>
ConfigurationContext.Chain(owner, nameof(Field))
.Argument(propertyInfo.Name)
.Argument(expression);
return _addFieldMethodInfo.MakeGenericMethod(propertyType).InvokeAndHoistBaseException<IField<TExecutionContext>>(
this,
configurationContextFactory,
propertyInfo.Name,
expression,
null);
}