示例#1
0
 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));
     });
 }
示例#2
0
 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)));
     });
 }
示例#3
0
        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));
            });
        }