Can i intercept the iqueryable ? #4039
Answered
by
PascalSenn
lucas-garrido
asked this question in
Q&A
-
Hello ! |
Beta Was this translation helpful? Give feedback.
Answered by
PascalSenn
Aug 3, 2021
Replies: 1 comment
-
You can use a middleware to intercept the queries public class Query
{
[UseYourMiddleware]
[UseFiltering]
public IQueryable<Foo> GetFoos(...) => ...
} public class UseYourMiddlewareAttribute : ObjectFieldDescriptorAttribute
{
public override void OnConfigure(
IDescriptorContext context,
IObjectFieldDescriptor descriptor,
MemberInfo member)
{
descriptor.Use(next => async context =>
{
await next(context);
if (context.Result is IQueryable<Foo> q)
{
// intercept the IQueryable in q
}
});
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
lucas-garrido
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use a middleware to intercept the queries