public RootMutation(IHumanRepository humanRepository) { Name = "Mutation"; Description = "The mutation type, represents all updates we can make to our data."; FieldAsync <HumanGType, Human>( "createHuman", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <HumanInputObject> >() { Name = "human", Description = "The human you want to create." }), resolve: context => { var human = context.GetArgument <Human>("human"); return(humanRepository.AddAsync(human, context.CancellationToken)); }); }
public StarWarsMutation(IHumanRepository humanRepository, IMapper mapper) { Name = "Mutation"; FieldAsync <HumanType>( "createHuman", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <HumanInputType> > { Name = "human" } ), resolve: async context => { var human = context.GetArgument <Human>("human"); var model = mapper.Map <Repositories.Models.Human>(human); await humanRepository.AddAsync(model); return(mapper.Map <Human>(model)); }); }