public CoreQuery(TempDBContext database) { Field <ListGraphType <OrganisationType> >( "organisations", resolve: context => database.Organisations() ); Field <OrganisationType>( "organisation", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }), resolve: context => { var id = new Guid(context.GetArgument <string>("id")); return(database.Organisations()); }); Field <ListGraphType <EmployerType> >( "employers", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "organisationId" }), resolve: context => { var id = new Guid(context.GetArgument <string>("organisationId")); return(database.Employers().Where(x => x.OrganisationId == id)); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, TempDBContext tempDBContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/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(); } tempDBContext.Database.EnsureCreated(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); }
public CoreMutation(TempDBContext database, EmployerMessagingService employerMessageService) { FieldAsync <EmployerType>( "createEmployer", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <EmployerInputType> > { Name = "employer" }), resolve: async context => { var employer = context.GetArgument <Employer>("employer"); database.Employers().Add(employer); employerMessageService.AddEmployerAddedMessage(employer); return(employer); }); }
public UserRepository(TempDBContext context) { _context = context; }