File tree 3 files changed +60
-0
lines changed
3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Github \Api ;
4
+
5
+ /**
6
+ * GraphQL API.
7
+ *
8
+ * Part of the Github API Early-Access Program
9
+ *
10
+ * @link https://developer.github.com/early-access/graphql/
11
+ * @author Miguel Piedrafita <[email protected] >
12
+ */
13
+ class GraphQL extends AbstractApi
14
+ {
15
+ /**
16
+ * @param string $query
17
+ *
18
+ * @return array
19
+ */
20
+ public function execute ($ query )
21
+ {
22
+ $ params = array (
23
+ 'query ' => $ query
24
+ );
25
+
26
+ return $ this ->post ('/graphql ' , $ params );
27
+ }
28
+ }
Original file line number Diff line number Diff line change 54
54
* @method Api\Authorizations authorization()
55
55
* @method Api\Authorizations authorizations()
56
56
* @method Api\Meta meta()
57
+ * @method Api\GraphQL graphql()
57
58
*
58
59
* @author Joseph Bielawski <[email protected] >
59
60
*
@@ -267,6 +268,9 @@ public function api($name)
267
268
case 'meta ' :
268
269
$ api = new Api \Meta ($ this );
269
270
break ;
271
+ case 'graphql ' :
272
+ $ api = new Api \GraphQL ($ this );
273
+ break ;
270
274
271
275
default :
272
276
throw new InvalidArgumentException (sprintf ('Undefined api instance called: "%s" ' , $ name ));
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Github \Tests \Api ;
4
+
5
+ class GraphQLTest extends TestCase
6
+ {
7
+
8
+ /**
9
+ * @test
10
+ */
11
+ public function shouldTestGraphQL ()
12
+ {
13
+ $ api = $ this ->getApiMock ();
14
+
15
+ $ api ->expects ($ this ->once ())
16
+ ->method ('post ' )
17
+ ->with ($ this ->equalTo ('/graphql ' ), $ this ->equalTo (['query ' =>'bar ' ]))
18
+ ->will ($ this ->returnValue ('foo ' ));
19
+
20
+ $ result = $ api ->execute ('bar ' );
21
+ $ this ->assertEquals ('foo ' , $ result );
22
+ }
23
+
24
+ protected function getApiClass ()
25
+ {
26
+ return \Github \Api \GraphQL::class;
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments