-
Notifications
You must be signed in to change notification settings - Fork 63
different approach to async #467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ery. Support async in ResolveBulkUpdate docs.
|
New changes
The var schema = SchemaBuilder.FromObject<MyContext>();
schema.Type<Person>()
.AddField("weather", "Current weather for this person's location")
.ResolveAsync<WeatherService>((person, weatherService) =>
weatherService.GetWeatherAsync(person.Location));
EntityGraphQL provides three levels of concurrency control to help you manage resource usage and prevent overwhelming external services. All concurrency limits apply only to the currently executing query. Field-Level ConcurrencyLimit concurrency for individual fields: schema.Type<Person>()
.AddField("expensiveOperation", "Resource-intensive operation")
.ResolveAsync<ExpensiveService>((person, service) =>
service.DoExpensiveWorkAsync(person.Id),
maxConcurrency: 5); // Only 5 concurrent operations for this fieldService-Level ConcurrencyConfigure concurrency limits for entire services across all fields that use them: var executionOptions = new ExecutionOptions
{
ServiceConcurrencyLimits = new Dictionary<Type, int>
{
[typeof(WeatherService)] = 10, // Max 10 concurrent weather calls
[typeof(DatabaseService)] = 3, // Max 3 concurrent database operations
[typeof(EmailService)] = 2 // Max 2 concurrent email sends
}
};
var result = await schema.ExecuteRequestAsync(query, context, serviceProvider, executionOptions);Query-Level ConcurrencySet a global limit for all async operations in a single query: var executionOptions = new ExecutionOptions
{
MaxQueryConcurrency = 20 // Maximum 20 concurrent operations across entire query
};
var result = await schema.ExecuteRequestAsync(query, context, serviceProvider, executionOptions);Hierarchical Concurrency ControlEntityGraphQL applies concurrency limits hierarchically - each level respects the limits above it:
For example, with these settings:
The field will never exceed 3 concurrent operations, the WeatherService will never exceed 10 concurrent operations, and the entire query will never exceed 50 concurrent operations. |
Still some testing to do but the idea is
GetAwaiter())