public static IEnumerable Build()

in src/Service.GraphQLBuilder/Mutations/CreateMutationBuilder.cs [479:573]


        public static IEnumerable<FieldDefinitionNode> Build(
            NameNode name,
            Dictionary<NameNode, InputObjectTypeDefinitionNode> inputs,
            ObjectTypeDefinitionNode objectTypeDefinitionNode,
            DocumentNode root,
            DatabaseType databaseType,
            RuntimeEntities entities,
            string dbEntityName,
            string returnEntityName,
            IEnumerable<string>? rolesAllowedForMutation = null,
            bool IsMultipleCreateOperationEnabled = false)
        {
            List<FieldDefinitionNode> createMutationNodes = new();
            Entity entity = entities[dbEntityName];
            InputObjectTypeDefinitionNode input;
            if (!IsRelationalDb(databaseType))
            {
                input = GenerateCreateInputTypeForNonRelationalDb(
                    inputs,
                    objectTypeDefinitionNode,
                    name,
                    root.Definitions.Where(d => d is HotChocolate.Language.IHasName).Cast<HotChocolate.Language.IHasName>(),
                    databaseType);
            }
            else
            {
                input = GenerateCreateInputTypeForRelationalDb(
                    inputs: inputs,
                    objectTypeDefinitionNode: objectTypeDefinitionNode,
                    entityName: dbEntityName,
                    name: name,
                    baseEntityName: name,
                    definitions: root.Definitions.Where(d => d is HotChocolate.Language.IHasName).Cast<HotChocolate.Language.IHasName>(),
                    databaseType: databaseType,
                    entities: entities,
                    IsMultipleCreateOperationEnabled: IsMultipleCreateOperationEnabled);
            }

            List<DirectiveNode> fieldDefinitionNodeDirectives = new() { new(ModelDirectiveType.DirectiveName, new ArgumentNode(ModelDirectiveType.ModelNameArgument, dbEntityName)) };

            // Create authorize directive denoting allowed roles
            if (CreateAuthorizationDirectiveIfNecessary(
                    rolesAllowedForMutation,
                    out DirectiveNode? authorizeDirective))
            {
                fieldDefinitionNodeDirectives.Add(authorizeDirective!);
            }

            string singularName = GetDefinedSingularName(name.Value, entity);

            // Create one node.
            FieldDefinitionNode createOneNode = new(
                location: null,
                name: new NameNode(GetPointCreateMutationNodeName(name.Value, entity)),
                description: new StringValueNode($"Creates a new {singularName}"),
                arguments: new List<InputValueDefinitionNode> {
                        new(
                            location : null,
                        new NameNode(MutationBuilder.ITEM_INPUT_ARGUMENT_NAME),
                        new StringValueNode($"Input representing all the fields for creating {name}"),
                        new NonNullTypeNode(new NamedTypeNode(input.Name)),
                        defaultValue: null,
                        new List<DirectiveNode>())
                },
                type: new NamedTypeNode(returnEntityName),
                directives: fieldDefinitionNodeDirectives
            );

            createMutationNodes.Add(createOneNode);

            // Multiple create node is created in the schema only when multiple create operation is enabled.
            if (IsMultipleCreateOperationEnabled)
            {
                // Create multiple node.
                FieldDefinitionNode createMultipleNode = new(
                    location: null,
                    name: new NameNode(GetMultipleCreateMutationNodeName(name.Value, entity)),
                    description: new StringValueNode($"Creates multiple new {GetDefinedPluralName(name.Value, entity)}"),
                    arguments: new List<InputValueDefinitionNode> {
                        new(
                            location : null,
                            new NameNode(MutationBuilder.ARRAY_INPUT_ARGUMENT_NAME),
                            new StringValueNode($"Input representing all the fields for creating {name}"),
                            new ListTypeNode(new NonNullTypeNode(new NamedTypeNode(input.Name))),
                            defaultValue: null,
                            new List<DirectiveNode>())
                    },
                    type: new NamedTypeNode(QueryBuilder.GeneratePaginationTypeName(GetDefinedSingularName(dbEntityName, entity))),
                    directives: fieldDefinitionNodeDirectives
                );
                createMutationNodes.Add(createMultipleNode);
            }

            return createMutationNodes;
        }