예제 #1
0
        private static void IntegrateFields(
            ObjectTypeDefinitionNode rootType,
            ITypeInfo typeInfo,
            ISet <string> names,
            ICollection <FieldDefinitionNode> fields)
        {
            string schemaName = typeInfo.Schema.Name;

            foreach (FieldDefinitionNode field in rootType.Fields)
            {
                FieldDefinitionNode current = field;

                if (names.Add(current.Name.Value))
                {
                    current = current.AddDelegationPath(schemaName);
                }
                else
                {
                    var path = new SelectionPathComponent(
                        field.Name,
                        field.Arguments.Select(t => new ArgumentNode(
                                                   t.Name,
                                                   new ScopedVariableNode(
                                                       null,
                                                       new NameNode(ScopeNames.Arguments),
                                                       t.Name))).ToList());

                    var newName = new NameNode(
                        typeInfo.CreateUniqueName(current));

                    current = current.WithName(newName)
                              .AddDelegationPath(schemaName, path);
                }

                fields.Add(current);
            }
        }