public static FieldDefinitionNode Build()

in src/Service.GraphQLBuilder/Mutations/UpdateAndPatchMutationBuilder.cs [204:276]


        public static FieldDefinitionNode Build(
            NameNode name,
            Dictionary<NameNode, InputObjectTypeDefinitionNode> inputs,
            ObjectTypeDefinitionNode objectTypeDefinitionNode,
            DocumentNode root,
            RuntimeEntities entities,
            string dbEntityName,
            DatabaseType databaseType,
            string returnEntityName,
            IEnumerable<string>? rolesAllowedForMutation = null,
            EntityActionOperation operation = EntityActionOperation.Update,
            string operationNamePrefix = UPDATE_MUTATION_PREFIX)
        {
            InputObjectTypeDefinitionNode input = GenerateUpdateInputType(
                inputs,
                objectTypeDefinitionNode,
                name,
                root.Definitions.Where(d => d is HotChocolate.Language.IHasName).Cast<HotChocolate.Language.IHasName>(),
                entities,
                databaseType,
                operation);

            List<FieldDefinitionNode> idFields = FindPrimaryKeyFields(objectTypeDefinitionNode, databaseType);
            string description;
            if (idFields.Count() > 1)
            {
                description = "One of the ids of the item being updated.";
            }
            else
            {
                description = "The ID of the item being updated.";
            }

            List<InputValueDefinitionNode> inputValues = new();
            foreach (FieldDefinitionNode idField in idFields)
            {
                inputValues.Add(new InputValueDefinitionNode(
                    location: null,
                    idField.Name,
                    new StringValueNode(description),
                    new NonNullTypeNode(idField.Type.NamedType()),
                    defaultValue: null,
                    new List<DirectiveNode>()));
            }

            inputValues.Add(new InputValueDefinitionNode(
                    location: null,
                    new NameNode(INPUT_ARGUMENT_NAME),
                    new StringValueNode($"Input representing all the fields for updating {name}"),
                    new NonNullTypeNode(new NamedTypeNode(input.Name)),
                    defaultValue: null,
                    new List<DirectiveNode>()));

            // Create authorize directive denoting allowed roles
            List<DirectiveNode> fieldDefinitionNodeDirectives = new() { new(ModelDirectiveType.DirectiveName, new ArgumentNode(ModelDirectiveType.ModelNameArgument, dbEntityName)) };

            if (CreateAuthorizationDirectiveIfNecessary(
                    rolesAllowedForMutation,
                    out DirectiveNode? authorizeDirective))
            {
                fieldDefinitionNodeDirectives.Add(authorizeDirective!);
            }

            string singularName = GetDefinedSingularName(name.Value, entities[dbEntityName]);
            return new(
                location: null,
                name: new NameNode($"{operationNamePrefix}{singularName}"),
                description: new StringValueNode($"Updates a {singularName}"),
                arguments: inputValues,
                type: new NamedTypeNode(returnEntityName),
                directives: fieldDefinitionNodeDirectives
            );
        }