Closed jaulz closed 7 months ago
@spawnia sorry, you are right and I phrased it wrong/didn't understand it correctly before. In fact I meant the argument set transformers which are registered by the FieldMiddleware
, e.g. the ValidateDirective
like I mentioned in my example.
Yeah, I could see passing the context to them. It would be a breaking change to the interface, so it would have to wait until the next major version. Open for pull requests.
What problem does this feature proposal attempt to solve?
It would be great if we could access the
$context
inFieldMiddleware
so we can for example access the resolved user. In my specific case I would like to access the authenticated user (via context) in the ValidateDirective so I can only allow specific input values that are available to the user. Right now, I can simply useauth()->user()
but it does not feel 100% right (or am I wrong?).Which possible solutions should be considered?
I assume it must be implemented here but I haven't got any nice idea about a backward compatible change: https://github.com/nuwave/lighthouse/blob/fa7af9d17958b5c4d4e7bde7c4dfd7d0dcff06db/src/Schema/Values/FieldValue.php#L158-L187