@@ -39,7 +39,7 @@ class GraphQLAction extends Action
39
39
/**
40
40
* @var array child graphql actions
41
41
*/
42
- private $ actions = [];
42
+ private $ authActions = [];
43
43
/**
44
44
* @var callable a PHP callable that will be called when running an action to determine
45
45
* if the current user has the permission to execute the action. If not set, the access
@@ -95,10 +95,21 @@ public function getGraphQLActions()
95
95
if ($ this ->schemaArray === true ) {
96
96
return [self ::INTROSPECTIONQUERY => 'true ' ];
97
97
}
98
- if (!$ this ->actions ) {
99
- $ this ->actions = array_merge ($ this ->schemaArray [0 ], $ this ->schemaArray [1 ]);
98
+ $ ret = array_merge ($ this ->schemaArray [0 ], $ this ->schemaArray [1 ]);
99
+ if (!$ this ->authActions ) {
100
+ //init
101
+ $ this ->authActions = array_merge ($ this ->schemaArray [0 ], $ this ->schemaArray [1 ]);
100
102
}
101
- return $ this ->actions ;
103
+ return $ ret ;
104
+ }
105
+
106
+ /**
107
+ * remove action that no need check access
108
+ * @param $key
109
+ */
110
+ public function removeGraphQlAction ($ key )
111
+ {
112
+ unset($ this ->authActions [$ key ]);
102
113
}
103
114
104
115
/**
@@ -111,8 +122,8 @@ public function run()
111
122
//调度状态下将执行构建查询
112
123
$ this ->controller ->module ->enableValidation ();
113
124
}
114
- if ($ this ->actions && $ this ->checkAccess ) {
115
- foreach ($ this ->actions as $ childAction ) {
125
+ if ($ this ->authActions && $ this ->checkAccess ) {
126
+ foreach ($ this ->authActions as $ childAction ) {
116
127
call_user_func ($ this ->checkAccess , $ childAction );
117
128
}
118
129
}
0 commit comments