fidelize / graphql-laravel-authorize-introspection
rebing/graphql-laravel 的授权 introspection 文档
1.1.1
2019-07-10 21:24 UTC
Requires
- rebing/graphql-laravel: >=1.15.9
Requires (Dev)
- mockery/mockery: ^1.2
- phpunit/phpunit: ^5.5|~6.0|~7.0
This package is auto-updated.
Last update: 2024-09-11 14:42:06 UTC
README
rebing/graphql-laravel 在执行 introspection 时列出所有查询、突变和订阅,即使这些查询在调用时未经授权(因为它们的 #authorize
方法中的规则)。
此扩展允许我们
- 为调用查询和 introspecting 查询定义不同的规则。
- 仅在 introspection 中列出允许的查询、突变和订阅。
例如:您可能希望使用 authorizeIntrospection
列出所有作者的 updatePost
突变,但在调用 updatePost
时只允许作者编辑自己的帖子。因此
authorizeIntrospection
: 允许显示文档。authorize
: 允许使用给定的参数调用它。
在您的查询、突变和订阅基类中,您可能想要添加
<?php namespace App\GraphQL\Mutation; use Rebing\GraphQL\Support\Mutation; class AbstractMutation extends Mutation { public function authorizeIntrospection() { // Your rule here return true; } public function authorize(array $args) { // Only override when you have custom rule according to the $args return $this->authorizeIntrospection(); } }
安装
composer require "fidelize/graphql-laravel-authorize-introspection"
在您的 config/app.php
文件中将 Rebing\GraphQL\GraphQLServiceProvider
替换为 Fidelize\GraphQLAuthorizedIntrospection\ServiceProvider
。