private Type GenerateGraphType()

in src/Epam.GraphQL/Configuration/RelationRegistry.cs [735:774]


        private Type GenerateGraphType(Type type, bool generateInputType)
        {
            if (TryGetGraphValueType(type, out var graphType))
            {
                return typeof(NonNullGraphType<>).MakeGenericType(graphType);
            }

            if (type == typeof(string))
            {
                return typeof(StringGraphType);
            }

            if (type.IsEnumerableOfT())
            {
                var elementType = GenerateGraphType(type.GetEnumerableElementType(), generateInputType);
                var listGraphType = typeof(ListGraphType<>);
                return listGraphType.MakeGenericType(elementType);
            }

            if (type.IsNullable())
            {
                var elementType = type.UnwrapIfNullable();
                if (TryGetGraphValueType(elementType, out graphType))
                {
                    return graphType;
                }

                throw new InvalidOperationException($"The type: Nullable<{elementType.HumanizedName()}> cannot be coerced effectively to a GraphQL type.");
            }

            if (type.IsValueType)
            {
                throw new InvalidOperationException(
                    $"The type: {type.HumanizedName()} cannot be coerced effectively to a GraphQL type.");
            }

            return generateInputType
                ? typeof(InputAutoObjectGraphType<,>).MakeGenericType(type, typeof(TExecutionContext))
                : typeof(AutoObjectGraphType<,>).MakeGenericType(type, typeof(TExecutionContext));
        }