in src/Epam.GraphQL/Configuration/RelationRegistry.cs [439:486]
public string GetProjectionTypeName<TProjection, TEntity>(bool isInput)
where TProjection : ProjectionBase<TEntity, TExecutionContext>, new()
{
var projectionType = typeof(TProjection);
var entityType = typeof(TEntity);
var typeName = projectionType.Name.Split('`')[0];
const string LoaderString = "Loader";
if (typeName.EndsWith(LoaderString, StringComparison.Ordinal))
{
var suffix = entityType.IsGenericType ? $"Of{string.Join("And", entityType.GetGenericArguments().Select(t => t.GraphQLTypeName(false)))}" : string.Empty;
var prefix = isInput ? "Input" : string.Empty;
typeName = typeName.Substring(0, typeName.Length - LoaderString.Length);
var name = $"{prefix}{typeName}{suffix}";
if (TryGetRegisteredType(name, out var types))
{
if (types.Entity == entityType && types.Projection == projectionType)
{
return name;
}
}
else if (!IsTypeNameRegistered(name))
{
return name;
}
var counter = 1;
while (IsTypeNameRegistered($"{name}{counter}"))
{
counter++;
}
name = $"{name}{counter}";
return name;
}
string? possibleName = null;
if (ReflectionHelpers.TryFindMatchingGenericBaseType(projectionType, typeof(Query<>), out var _) || ReflectionHelpers.TryFindMatchingGenericBaseType(projectionType, typeof(Mutation<>), out _))
{
possibleName = projectionType.GraphQLTypeName(false);
}
return GetGraphQLTypeName(entityType, projectionType, isInput, null, possibleName);
}