-
Notifications
You must be signed in to change notification settings - Fork 5
Pipes - missing documentation + bug #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hum, I don't really understand. If you want adding a pipe to check user role, you can simply create a generic pipe using the following syntax : class CheckContextRole {
public function handle($builder, \Closure $next, array $args, string $role) {
if ($args['context']->role !== $role) {
throw new \Exception('You\'re not allowed');
}
return $next($builder);
}
} and register it like /**
* {@inheritDoc}
*
* @return array
*/
public function getPipes(): array {
return array_merge_recursive(parent::getPipes(), [
// 'store' => \App\GraphQL\Pipe\CheckContextRole::class . ':admin']
'all' => [\App\GraphQL\Pipe\CheckContextRole::class . ':admin']
]);
} |
Yes, I currently do it already like you described =) I figured it out while I was looking at your code and I understood it, but it would be nice, if it would be documented, so other people can unterstand and use it easy. Also there is a bug. Have you looked at my PR? in |
Oh ! I'll document pipeline soon. I've didn't really understood why the PR but it makes sense. I'll merge it when the README will explain pipeline. Thanks! |
It would be nice, if using of pipes in definition would be documented. I also asked you, if it is possible to use pipes for authentication or other type of permission check is possible. You replied with "no", but actually it is possible. By the way, HTTP Middlewares in laravel, like auth middleware, works just the same.
I thing I got the idea of pipes, it is really nice! I also noticed, that it is generally possible to define pipe in following format:
Class\Name\Of\Pipe:argument,another argument
. So pipline can parse this string format, and get the class of pipe for creating it from container, and passes to thehandle()
method some addition parameters, in the example above:argument
andanother argument
as 4th and 5th argument. It works well with pipeline code, but you also use pipes for gql fields generation... and this part of code dont accept this string format. May we fix it? As I would like to add a pipe for checking user role.I'll do a merge request, so you can see what I mean... When we merge fix-bug, I can also write a small doc for pipe usage
The text was updated successfully, but these errors were encountered: