public async Task <AddFoodItemPayload> AddFoodItemAsync( AddFoodItemInput input, [ScopedService] GraphqlDbContext context ) { var foodItem = new FoodItem { Name = input.Name, Amount = input.Amount, Unit = input.Unit, Price = input.Price }; context.FoodItems.Add(foodItem); await context.SaveChangesAsync(); return(new AddFoodItemPayload(foodItem)); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, GraphqlDbContext db) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } //app.UseHttpsRedirection(); //app.UseStaticFiles(); //app.UseCookiePolicy(); //app.UseMvc(); app.UseGraphQL <GraphqlDemoSchema>(); app.UseGraphQLPlayground(new GraphQLPlaygroundOptions()); db.Seed(); }
public ProductReviewRepository(GraphqlDbContext dbContext) { _dbContext = dbContext; }
public EntityFrameworkDataStoreService(GraphqlDbContext dbContext) { _dbContext = dbContext; }
public IQueryable <FoodItem> GetFoodItems([ScopedService] GraphqlDbContext context) { return(context.FoodItems); }