My Lighthouse's (v5.0.2) default guard is 'web', but I use an 'admin' guard also.
Default guard context works properly in any case, but when I need to use admin's context – it returns null.
(Whereas admin guard works correctly like a guard: it protects field and mutations as expected).
There is a mutation example:
addNote(text: String!): Note! @create @inject(context: "user.id", name: "admin_id") @guard(with: "admin")
I've tried to create a custom mutator and it possible to get an access to admin's context via
$context->request()->user();
(Whereas for default guard $context->user works also)
But if I have a lot of simple mutations like @create, @update, etc., do I really need to create multiple custom mutator methods in this case instead of just using @inject directive?
And another problem: if I need to give an access to the same mutation to multiple guards, I do need to write it twice (or more) and name differently.
My Lighthouse's (v5.0.2) default guard is 'web', but I use an 'admin' guard also. Default guard context works properly in any case, but when I need to use admin's context – it returns null. (Whereas admin guard works correctly like a guard: it protects field and mutations as expected).
There is a mutation example:
addNote(text: String!): Note! @create @inject(context: "user.id", name: "admin_id") @guard(with: "admin")
I've tried to create a custom mutator and it possible to get an access to admin's context via
$context->request()->user();
(Whereas for default guard $context->user works also)But if I have a lot of simple mutations like
@create
,@update
, etc., do I really need to create multiple custom mutator methods in this case instead of just using@inject
directive?And another problem: if I need to give an access to the same mutation to multiple guards, I do need to write it twice (or more) and name differently.
Do I misunderstand something?
Many thanks!