graphql-middleware
graphql-middleware copied to clipboard
Be able to blacklist queries/mutations
Hey, thanks for a great library!
I was wondering if it's possible to blacklist instead of whitelisting queries/mutations? I.e. this is how we do it today:
export const authMiddleware = {
Query: {
getUsers: isAuthenticated,
}
}
Where isAuthenticated is applied for the getUsers query. However, now I need to add every single query in here or do the following:
export const authMiddleware = {
Query: isAuthenticated,
}
which applies it to all queries. However, I want some queries to be able to get without being authenticated. It would be nice if you could do something like:
export const authMiddleware = {
Query: isAuthenticated,
except: ['getPublicProfile', 'getBlogPost']
}
Or is this possible in any way at the moment?
I am afraid there's no obvious solution for that in graphql-middleware, at least nothing from the top of my head, but you could check out graphql-shield.
Alright, thanks for the answer! That's too bad. It's easy to forgot to add the middleware function to one query so it would have been nice if it existed.