I want to call a http middleware for all mutation/query call in GraphQL, but do not want to call for one query ? Is that possible ?
Edit :
I want to send user deactivated response, for all api which needs user to be logged-in, if user is soft deleted. But I do not want this for api to restore the user again.
CodePudding user response:
No, this is not possible. I will not add such a feature to Lighthouse.
If you need specific logic based on which GraphQL fields are used, that belongs in field middleware. HTTP and GraphQL are two separate layers and must not be conflated.
CodePudding user response:
No this is not possible in Lighthouse.
I would recommend solving this with @guard directive.
https://lighthouse-php.com/5/security/authentication.html#attemptauthentication-middleware
So basically do something like
extend type Query {
restore(email: String!, password: String!): User
}
And then for all other queries
extend type Query @guard {
viewer: User! @auth
}
By default if a user is soft deleted, then auth:api would not allow it to log in, so no reason to do any changes to the guard.
