Configure GraphQL execution in ASP.NET Core
masterThe server can be integrated into the ASP.NET Core pipeline using several different patterns:
- Middleware: Configure via
IApplicationBuilderorIEndpointRouteBuilderto serve requests as middleware. - Route Handlers: Use .NET 6+ route handlers (e.g.,
MapGet,MapPost) by returning specific result types:GraphQLExecutionHttpResult: For direct GraphQL execution.ExecutionResultHttpResult: For returning pre-executed GraphQL responses.
- MVC Controllers: Return GraphQL responses from controller actions using:
GraphQLExecutionActionResultExecutionResultActionResult
Authorization Support
Includes AuthorizationValidationRule which validates that the schema, output graph types, fields, and query arguments meet the policies or roles defined in the ASP.NET Core authorization framework.
Note: It does not validate policies/roles for input graph types, input fields, or directives. It skips validation for fields/fragments marked with @skip or @include.