public InfoMutation() { Field <InfoType>( "addInfo", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <InfoInputType> > { Name = "info" } ), resolve: context => { var n = context.GetArgument <Info>("info"); return(InfoRepository.AddInfo(n)); }); Field <InfoType>( "addLike", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <InfoInputType> > { Name = "info" }, new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "infoId" }), resolve: context => { var info = context.GetArgument <Info>("info"); var infoID = context.GetArgument <string>("infoId"); var dbOwner = InfoRepository.GetByID(infoID); return(InfoRepository.UpdateInfo(infoID, info)); }); }
public InfoQuery() { Field <ListGraphType <InfoType> >("infos", resolve: context => InfoRepository.GetAll()); Field <InfoType>("info", arguments: new QueryArguments(new QueryArgument <IdGraphType> { Name = "name" }), resolve: context => { var name = context.GetArgument <string>("name"); return(InfoRepository.GetAll().FirstOrDefault(x => x.name == name)); }); }