Hi guys.
I want to use my own directive “isAuthenticated” for some fields and mutations.
User object or null is in context.user
.
And I’m trying to do smth like this:
isAuthenticated: (next, source, args, context) => {
if (context.user) {
return next()
} else {
throw new Error(`Must be logged in to view this field`)
}
}
And it works fine in GraphiQL: data object, error object, server got error, looks like OK.
But my React app completely crashes.
What have to be in else
-block???