Skip to content
This repository was archived by the owner on Feb 10, 2019. It is now read-only.

Commit 924bfa1

Browse files
committed
add setup method to field
1 parent 171631a commit 924bfa1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Folklore/GraphQL/Support/Field.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
class Field extends Fluent
99
{
1010

11+
/**
12+
* Override this in your queries or mutations
13+
* to setup models for authorize, authenticated, resolve
14+
*/
15+
public function setup($root, $args, $context)
16+
{
17+
return true;
18+
}
19+
1120
/**
1221
* Override this in your queries or mutations
1322
* to provide custom authorization
@@ -47,13 +56,17 @@ protected function getResolver()
4756
return null;
4857
}
4958

59+
$setup = array($this, 'setup');
5060
$resolver = array($this, 'resolve');
5161
$authenticate = [$this, 'authenticated'];
5262
$authorize = [$this, 'authorize'];
5363

54-
return function () use ($resolver, $authorize, $authenticate) {
64+
return function () use ($setup, $resolver, $authorize, $authenticate) {
5565
$args = func_get_args();
5666

67+
//Setup
68+
call_user_func_array($setup, $args);
69+
5770
// Authenticated
5871
if (call_user_func_array($authenticate, $args) !== true) {
5972
throw new AuthorizationError('Unauthenticated');

0 commit comments

Comments
 (0)