Esempio n. 1
0
        public async Task <Human> CreateHumanAsync(
            [Service] IImmutableMapper <HumanInput, Human> humanInputToHumanMapper,
            [Service] IHumanRepository humanRepository,
            HumanInput humanInput,
            CancellationToken cancellationToken)
        {
            var human = humanInputToHumanMapper.Map(humanInput);

            human = await humanRepository
                    .AddHumanAsync(human, cancellationToken)
                    .ConfigureAwait(false);

            return(human);
        }
Esempio n. 2
0
        public MutationObject(IClockService clockService, IHumanRepository humanRepository)
        {
            this.Name        = "Mutation";
            this.Description = "The mutation type, represents all updates we can make to our data.";

            this.FieldAsync <HumanObject, Human>(
                "createHuman",
                "Create a new human.",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <HumanInputObject> >()
            {
                Name        = "human",
                Description = "The human you want to create.",
            }),
                resolve: context =>
            {
                var human      = context.GetArgument <Human>("human");
                var now        = clockService.UtcNow;
                human.Created  = now;
                human.Modified = now;
                return(humanRepository.AddHumanAsync(human, context.CancellationToken));
            });
        }