-
-
Notifications
You must be signed in to change notification settings - Fork 748
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
Field middleware not working for introspection fields #853
Comments
Sorry for the wait ... will tell you how this works tomorrow. |
@michaelstaib , sorry for disturbing you, but could you please point me to the right place where I can add additional security check (special scope) for introspection query? |
Hi, sorry for letting that hang so long. When we designed hc we did on purpose exclude middlewares from introspection resolvers since by adding transformations you could make your server non-spec compliant. Reflecting on that we could opt to allow this with an additional schema option. I will move this to the next release. |
OK, this one is supported with 9.1 preview 44 [Fact]
public async Task FieldMiddlewareHasAnEffectOnIntrospectIfSwitchedOn()
{
// arrange
string query = "{ __typename a }";
ISchema schema = SchemaBuilder.New()
.AddQueryType<Query>()
.Use(next => async context =>
{
await next.Invoke(context);
if (context.Result is string s)
{
context.Result = s.ToUpperInvariant();
}
})
.ModifyOptions(o =>
o.FieldMiddleware = FieldMiddlewareApplication.AllFields)
.Create();
IQueryExecutor executor = schema.MakeExecutable();
// act
IExecutionResult result = await executor.ExecuteAsync(query);
// assert
Assert.Empty(result.Errors);
result.MatchSnapshot();
} |
Describe the bug
Field middleware is not executing for introspection fields
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Middleware should work for all fields. As an option, could you please suggest how I can distinguish introspection query and add additional logic for it.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: