public void Configure()

in src/Epam.GraphQL/Configuration/Implementations/ProxyAccessor.cs [96:167]


        public void Configure()
        {
            lock (_configureLock)
            {
                if (_proxyGenericType != null)
                {
                    return;
                }

                var fieldTypes = new Dictionary<string, Type>();
                var i = 1;

                foreach (var dep in _conditionMembers)
                {
                    foreach (var depExpr in dep.Value.DependentOn)
                    {
                        AddNewField(dep.Key, depExpr);
                    }
                }

                foreach (var e in _members)
                {
                    AddNewField(string.Empty, e);
                }

                _proxyGenericType = fieldTypes.MakeProxyType(BaseProxyGenericType, typeof(TEntity).Name);

                void AddNewField(string fieldPrefix, LambdaExpression depExpr)
                {
                    if (!_expressionNames.ContainsKey(depExpr))
                    {
                        // Try to look up for existing expression field with the same lambda expression
                        var existingField = Fields
                            .OfType<IExpressionFieldConfiguration<TEntity, TExecutionContext>>()
                            .FirstOrDefault(existing =>
                                ExpressionEqualityComparer.Instance.Equals(existing.OriginalExpression, depExpr));

                        string? newName = null;

                        if (existingField != null)
                        {
                            // The expression field exists. Use its name
                            newName = existingField.Name.ToCamelCase();
                        }
                        else if (depExpr.IsProperty())
                        {
                            // This is the case when expression field doesn't exist, but expression itself is a property,
                            // so try to use a name of that property.
                            var propName = depExpr.GetPropertyInfo().Name.ToCamelCase();

                            // Try to lookup for existing non-expression field with the property name
                            if (!Fields.Any(
                                    field => field.Name.ToCamelCase().Equals(propName, StringComparison.Ordinal)))
                            {
                                // Field with the property name doesn't exist. Use a name of the property
                                newName = propName;
                                fieldTypes.Add(newName, depExpr.Body.Type);
                            }
                        }

                        if (newName == null)
                        {
                            // No match with existing names. Use generic name
                            newName = $"{fieldPrefix}${i++}";
                            fieldTypes.Add(newName, depExpr.Body.Type);
                        }

                        _expressionNames.Add(depExpr, newName);
                    }
                }
            }
        }