-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClientInterface.php
127 lines (113 loc) · 3.19 KB
/
ClientInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
namespace GraphQLClientPhp\Client;
interface ClientInterface
{
/**
* This function is placed to name you query.
* For example to use a query in a same page with different results.
* By default, the query name will be "anonymous" + a counter.
*
* @param string $name
*
* @return ClientInterface
*/
public function setName(string $name): ClientInterface;
/**
* This function return variables stored for the query by an array.
* It used the VariableBasicParser.
*
* @return array
*/
public function getVariables(): array;
/**
* This function is to set at VariableBasicParser the variables as an array.
*
* @param array $variables
*
* @return ClientInterface
*/
public function setVariables(array $variables): ClientInterface;
/**
* This function is to add at VariableBasicParser the association key => value.
*
* @param string $key
* @param $variable
*
* @return ClientInterface
*/
public function addVariable(string $key, $variable): ClientInterface;
/**
* Will return a array contains all queries not used.
*
* @return array
*/
public function getQueries(): array;
/**
* It used to set existing queries (probably in cache) as an array.
*
* @param array $queries
*
* @return ClientInterface
*/
public function setQueries(array $queries): ClientInterface;
/**
* Get the query by passing key in the stored query array.
*
* @param string $key
*
* @return string|null
*/
public function getQuery(string $key): ?string;
/**
* This function generate json sent to the API using parseQuery
* for prepared query or passing query string.
*
* @param string|null $query
*
* @return ClientInterface
*/
public function addQuery(string $query = null): ClientInterface;
/**
* This function will create the json query sent to the server.
* It parse query and variables if provided.
*
* @param string $query
*
* @return ClientInterface
*/
public function parseQuery(string $query): ClientInterface;
/**
* This function will get your query and will add fragments stored in
* the constructor class.
*
* @param string $query
*
* @return ClientInterface
*/
public function prepare(string $query): ClientInterface;
/**
* If passing $queryName, will return the result of query stored by name.
* If not, will return the first query result stored in the array of queries.
*
* @param string $queryName
*
* @return \stdClass|null
*/
public function sendQuery(string $queryName = null): ?\stdClass;
/**
* This function is a short cut of addQuery and sendQuery
*
* @param string $query
*
* @return \stdClass|null
*/
public function query(string $query): ?\stdClass;
/**
* Will use promise at async mode or getResult() to provide results from api.
*
* @param bool $async
*
* @return \stdClass[]
*/
public function sendQueries(bool $async = false): array;
}