in src/Epam.GraphQL/Configuration/Implementations/BaseObjectGraphTypeConfigurator.cs [997:1038]
private protected virtual void DoValidateFields()
{
if (!Fields.Any())
{
ConfigurationContext.AddError(
$"{(IsAuto ? $"Type `{typeof(TEntity).HumanizedName()}`" : "OnConfigure() method")} must have a declaration of one field at least.",
ConfigurationContext.Parent == null ? Array.Empty<IConfigurationContext>() : new[] { ConfigurationContext.Parent });
}
// Find dulicates and add errors for them
foreach (var group in Fields
.GroupBy(field => field.Name)
.Where(group => group.Count() > 1))
{
ConfigurationContext.AddError(
$"A field with the name `{group.Key}` is already registered.",
group.Select(field => field.ConfigurationContext).ToArray());
}
foreach (var group in InlineFilters
.GroupBy(filter => filter.FieldName)
.Where(group => group.Count() > 1))
{
ConfigurationContext.AddError(
$"A filter for field with the name `{group.Key}` is already registered.",
group.Select(filter => filter.ConfigurationContext).ToArray());
}
foreach (var group in Sorters
.GroupBy(sorter => sorter.Name)
.Where(group => group.Count() > 1))
{
ConfigurationContext.AddError(
$"A sorter with the name `{group.Key}` is already registered.",
group.Select(sorter => sorter.ConfigurationContext).ToArray());
}
if (!IsAuto)
{
Fields.ForEach(f => f.Validate());
}
}