Enabling a GraphQL endpoint in your ASP.NET Core application is quite easy thanks to the GraphQL.Server.Transports.AspNetCore NuGet package.
One of the nice features of GraphQL is that you can extend your resolvers using custom middleware. In the GraphQL.NET documentation they refer to the FieldsMiddleware property to register this extra middleware:
Unfortunately when using the GraphQL.Server package you only have an GraphQLOptions object but the only thing you can do is set a SetFieldMiddleware flag:
To register your own middleware you have to jump through some extra hoops:
- Create a custom GraphQLExecutor and override the GetOptions method:
- Register this Executor instance in your IoC container(here I'm using StructureMap):