1 | <?php |
||
9 | class ResolveContext implements RefinableCacheableDependencyInterface { |
||
10 | use RefinableCacheableDependencyTrait; |
||
11 | |||
12 | /** |
||
13 | * Read-only list of global values. |
||
14 | * |
||
15 | * @var array |
||
16 | */ |
||
17 | protected $globals; |
||
18 | |||
19 | /** |
||
20 | * The context stack. |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $contexts = []; |
||
25 | |||
26 | /** |
||
27 | * ResolveContext constructor. |
||
28 | * |
||
29 | * @param array $globals |
||
30 | * List of global values to expose to field resolvers. |
||
31 | */ |
||
32 | public function __construct(array $globals = []) { |
||
35 | |||
36 | /** |
||
37 | * Get a contextual value for the current field. |
||
38 | * |
||
39 | * Allows field resolvers to inherit contextual values from their ancestors. |
||
40 | * |
||
41 | * @param string $name |
||
42 | * The name of the context. |
||
43 | * @param \GraphQL\Type\Definition\ResolveInfo $info |
||
44 | * The resolve info object. |
||
45 | * @param mixed $default |
||
46 | * An arbitrary default value in case the context is not set. |
||
47 | * |
||
48 | * @return mixed |
||
49 | * The current value of the given context or the given default value if the |
||
50 | * context wasn't set. |
||
51 | */ |
||
52 | public function getContext($name, ResolveInfo $info, $default = NULL) { |
||
66 | |||
67 | /** |
||
68 | * Sets a contextual value for the current field and its decendents. |
||
69 | * |
||
70 | * Allows field resolvers to set contextual values which can be inherited by |
||
71 | * their descendents. |
||
72 | * |
||
73 | * @param string $name |
||
74 | * The name of the context. |
||
75 | * @param $value |
||
76 | * The value of the context. |
||
77 | * @param \GraphQL\Type\Definition\ResolveInfo $info |
||
78 | * The resolve info object. |
||
79 | * |
||
80 | * @return $this |
||
81 | */ |
||
82 | public function setContext($name, $value, ResolveInfo $info) { |
||
89 | |||
90 | /** |
||
91 | * Retrieve a global/static parameter value. |
||
92 | * |
||
93 | * @param string $name |
||
94 | * The name of the global parameter. |
||
95 | * @param mixed $default |
||
96 | * An arbitrary default value in case the context is not set. |
||
97 | * |
||
98 | * @return mixed|null |
||
99 | * The requested global parameter value or the given default value if the |
||
100 | * parameter is not set. |
||
101 | */ |
||
102 | public function getGlobal($name, $default = NULL) { |
||
109 | |||
110 | } |
||
111 |