in src/Epam.GraphQL/Configuration/Implementations/BaseObjectGraphTypeConfigurator.cs [157:200]
public ExpressionField<TEntity, TReturnType, TExecutionContext> AddField<TReturnType>(
Func<IChainConfigurationContextOwner, IChainConfigurationContext> configurationContextFactory,
string? name,
Expression<Func<TEntity, TReturnType>> expression,
string? deprecationReason)
{
MethodInfo? addFieldMethodInfo = null;
if (typeof(TReturnType) == typeof(string))
{
_addExpressionStringFieldMethodInfo = ReflectionHelpers.GetMethodInfo<Func<IChainConfigurationContextOwner, IChainConfigurationContext>, string, Expression<Func<TEntity, string>>, string?, ExpressionField<TEntity, string, TExecutionContext>>(
AddExpressionField);
addFieldMethodInfo = _addExpressionStringFieldMethodInfo;
}
else if (typeof(TReturnType).IsValueType)
{
var unwrappedUnderlyingType = typeof(TReturnType).UnwrapIfNullable();
var isNullable = typeof(TReturnType) != unwrappedUnderlyingType;
if (isNullable)
{
_addExpressionNullableFieldMethodInfo ??= ReflectionHelpers.GetMethodInfo<Func<IChainConfigurationContextOwner, IChainConfigurationContext>, string?, Expression<Func<TEntity, int?>>, string?, ExpressionField<TEntity, int?, TExecutionContext>>(
AddExpressionField);
addFieldMethodInfo = _addExpressionNullableFieldMethodInfo.MakeGenericMethod(unwrappedUnderlyingType);
}
else
{
_addExpressionFieldMethodInfo ??= ReflectionHelpers.GetMethodInfo<Func<IChainConfigurationContextOwner, IChainConfigurationContext>, string?, Expression<Func<TEntity, int>>, string?, ExpressionField<TEntity, int, TExecutionContext>>(
AddExpressionField);
addFieldMethodInfo = _addExpressionFieldMethodInfo.MakeGenericMethod(unwrappedUnderlyingType);
}
}
else
{
_addExpressionObjectFieldMethodInfo ??= ReflectionHelpers.GetMethodInfo<Func<IChainConfigurationContextOwner, IChainConfigurationContext>, string, Expression<Func<TEntity, object>>, string?, ExpressionField<TEntity, object, TExecutionContext>>(
AddObjectExpressionField);
addFieldMethodInfo = _addExpressionObjectFieldMethodInfo.MakeGenericMethod(typeof(TReturnType));
}
return addFieldMethodInfo.InvokeAndHoistBaseException<ExpressionField<TEntity, TReturnType, TExecutionContext>>(this, configurationContextFactory, name, expression, deprecationReason);
}