Bug: repeatedly calling middleware for each key of returning value
See original GitHub issueHi everyone, first I want to thank you for this great library, I have used it with Apollo server, all worked great intend of repeatedly calling, it’s calling middleware for each field returned from a handler, and args
argument is empty
export const authMiddleware = async (resolve, root, args, ctx: Context, info) => {
const mutationField = info.schema.getMutationType();
const mutationDefinition = mutationField.getFields()[info.fieldName];
if (mutationDefinition && mutationDefinition.auth) {
try {
const token = ctx.headers['authorization'].replace('Bearer ', '');
const data = await Crypto.decodeJwt<{ id: string }>(token);
const user = await User.findOne(data.id);
ctx.state.auth = {
user,
data,
token
};
} catch (e) {
throw new AuthenticationError('unauthorized');
}
}
const data = await resolve(root, args, ctx, info);
console.log(data);
return data;
};
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
Top Results From Across the Web
c# - .net-core middleware return blank result - Stack Overflow
What I want is that a blank page or an error message like "Invalid User Key" is shown if the user has no...
Read more >Use Custom Middleware to Detect and Fix 404s in ASP.NET ...
This middleware will check to see if the current request matches a particular path, and will ignore (and pass through) any requests that...
Read more >Using Middleware in .NET 5.0 to Log Requests and Responses
In any case, I needed a way to record requests and responses, and in .NET 5.0 the simplest way to do this was...
Read more >Rate Limiting in ASP.NET Core Web API - Code Maze
Rate Limiting in ASP.NET Core Web API is the process of restricting the number of requests for a resource within a specific time...
Read more >Top 10 Most Common Node.js Developer Mistakes - Toptal
In many asynchronous functions, the return value has almost no significance, so this approach often makes it easy to avoid such a problem....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You need to define your middleware to only apply to queries/mutations so it doesn’t apply to every field in a result:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.