public Recepy(IRecepyService recepyService, IDataLoaderContextAccessor dataLoaderContextAccessor) { Field(t => t.Id); Field(t => t.Name); Field <RecepyTypeEnumType>("Type", "RecepyType"); Field <ListGraphType <Ingredient> >("ingredients", resolve: context => { var loader = dataLoaderContextAccessor.Context.GetOrAddCollectionBatchLoader <int, IngredientModel>( "GetById", recepyService.GetIngredientsById); return(loader.LoadAsync(context.Source.Id)); }); }
public ElasticGraphMutation(IRecepyService recepyService) { FieldAsync <Recepy>( "addRecepy", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <RecepyInputType> > { Name = "recepy" }), resolve: async context => { var recepy = context.GetArgument <RecepyModel>("recepy"); return(await context.TryAsyncResolve( async c => await recepyService.AddRecepy(recepy))); }); }
public ElasticGraphQuerry(IIngredientService ingredientService, IRecepyService recepyService) { Field <ListGraphType <Ingredient> >( "ingredients", resolve: context => ingredientService.GetAll()); Field <ListGraphType <Recepy> >( "recepies", resolve: context => recepyService.GetAllRecepies()); Field <Recepy>( "recepy", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }), resolve: context => { var id = context.GetArgument <int>("id"); return(recepyService.GetById(id)); }); }