public async Task HttpPost_Ensure_Scoped_Services_Work() { // arrange TestServer server = ServerFactory.Create( services => { services.AddScoped <ScopedService>(); services.AddGraphQL(SchemaBuilder.New() .AddQueryType(c => c .Name("Query") .Field("foo") .Resolver(ctx => { ScopedService service = ctx.Service <ScopedService>(); service.Increase(); return(service.Count); }))); }, app => app .Use(next => ctx => { ScopedService service = ctx.RequestServices.GetService <ScopedService>(); service.Increase(); return(next(ctx)); }) .UseGraphQL()); var request = @" { foo } "; var contentType = "application/graphql"; // act HttpResponseMessage message = await server.SendPostRequestAsync(request, contentType, null); // assert ClientQueryResult result = await DeserializeAsync(message); result.MatchSnapshot(); }