From 08b2a34f6a1423de45b77dadd95856ee14030cd0 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 23 Jan 2017 18:37:47 +0100 Subject: [PATCH 01/14] Create GraphQL.php --- lib/Github/Api/GraphQL.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/Github/Api/GraphQL.php diff --git a/lib/Github/Api/GraphQL.php b/lib/Github/Api/GraphQL.php new file mode 100644 index 00000000000..091f87fce34 --- /dev/null +++ b/lib/Github/Api/GraphQL.php @@ -0,0 +1,23 @@ + + */ +class GraphQL extends AbstractApi +{ + /** + * @param string $query + * + * @return array + */ + public function graphql($query) + { + $params = array( + 'query' => $query + ); + return $this->post('/graphql', $params); + } +} From 3a1dd27dabd51d667d9d4cbc46984a9de033f5e9 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 23 Jan 2017 17:37:51 +0000 Subject: [PATCH 02/14] Apply fixes from StyleCI [ci skip] [skip ci] --- lib/Github/Api/GraphQL.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Github/Api/GraphQL.php b/lib/Github/Api/GraphQL.php index 091f87fce34..4adb0731540 100644 --- a/lib/Github/Api/GraphQL.php +++ b/lib/Github/Api/GraphQL.php @@ -1,5 +1,6 @@ $query ); + return $this->post('/graphql', $params); } } From abac0563dd2ead80988f3a18f0b59fbddff9c8a3 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 23 Jan 2017 18:39:23 +0100 Subject: [PATCH 03/14] Update Client.php --- lib/Github/Client.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Github/Client.php b/lib/Github/Client.php index eb7f3e727dd..ecb94f971de 100644 --- a/lib/Github/Client.php +++ b/lib/Github/Client.php @@ -54,6 +54,7 @@ * @method Api\Authorizations authorization() * @method Api\Authorizations authorizations() * @method Api\Meta meta() + * @method Api\GraphQL graphql() * * @author Joseph Bielawski * @@ -267,6 +268,9 @@ public function api($name) case 'meta': $api = new Api\Meta($this); break; + case 'graphql': + $api = new Api\GraphQL($this); + break; default: throw new InvalidArgumentException(sprintf('Undefined api instance called: "%s"', $name)); From a79b2b3d4a373969c93511d0e58c32b90eb45982 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Wed, 25 Jan 2017 19:40:31 +0100 Subject: [PATCH 04/14] Syntax --- lib/Github/Api/GraphQL.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Github/Api/GraphQL.php b/lib/Github/Api/GraphQL.php index 4adb0731540..a17d43cacb0 100644 --- a/lib/Github/Api/GraphQL.php +++ b/lib/Github/Api/GraphQL.php @@ -1,4 +1,5 @@ Date: Thu, 26 Jan 2017 09:35:09 +0100 Subject: [PATCH 05/14] Fix links --- lib/Github/Api/GraphQL.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Github/Api/GraphQL.php b/lib/Github/Api/GraphQL.php index a17d43cacb0..df150a17381 100644 --- a/lib/Github/Api/GraphQL.php +++ b/lib/Github/Api/GraphQL.php @@ -5,7 +5,7 @@ /** * GraphQL API. * - * @link http://developer.github.com/v3/markdown/ + * @link https://developer.github.com/early-access/graphql/ * @author Miguel Piedrafita */ class GraphQL extends AbstractApi From 25d30c1375d75509d6f48b235114dd383dc9192f Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Thu, 26 Jan 2017 09:36:28 +0100 Subject: [PATCH 06/14] Add Early Access note --- lib/Github/Api/GraphQL.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Github/Api/GraphQL.php b/lib/Github/Api/GraphQL.php index df150a17381..9b507ee634d 100644 --- a/lib/Github/Api/GraphQL.php +++ b/lib/Github/Api/GraphQL.php @@ -5,6 +5,7 @@ /** * GraphQL API. * + * Part of the Github API Early-Access Program * @link https://developer.github.com/early-access/graphql/ * @author Miguel Piedrafita */ From d31ef0b4eb2a22e21f46c1b32a6a175712ac1511 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Thu, 26 Jan 2017 09:47:53 +0100 Subject: [PATCH 07/14] Add Test --- test/Github/Tests/Api/GraphQLTest.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/Github/Tests/Api/GraphQLTest.php diff --git a/test/Github/Tests/Api/GraphQLTest.php b/test/Github/Tests/Api/GraphQLTest.php new file mode 100644 index 00000000000..37840a60cc7 --- /dev/null +++ b/test/Github/Tests/Api/GraphQLTest.php @@ -0,0 +1,25 @@ +class GraphQLTest extends TestCase +{ + // ... + + /** + * @test + */ + public function shouldShowGistComment() + { + $api = $this->getApiMock(); + + $api->expects($this->once()) + ->method('post') + ->with('/graphql', 'bar') + ->will($this->returnValue('foo')); + + $result = $api->graphql('bar'); + $this->assertEquals('foo', $result); + } + + protected function getApiClass() + { + return \Github\Api\GraphQL::class; + } +} From eb43204c0e0b90be74e59adb494bd42a1210bfb9 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Thu, 26 Jan 2017 09:51:11 +0100 Subject: [PATCH 08/14] Change function name --- lib/Github/Api/GraphQL.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Github/Api/GraphQL.php b/lib/Github/Api/GraphQL.php index 9b507ee634d..59fef2827bd 100644 --- a/lib/Github/Api/GraphQL.php +++ b/lib/Github/Api/GraphQL.php @@ -16,7 +16,7 @@ class GraphQL extends AbstractApi * * @return array */ - public function graphql($query) + public function execute($query) { $params = array( 'query' => $query From e9f57e65f49fea07eb2123c61fd70b5279f590ab Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Thu, 26 Jan 2017 09:51:49 +0100 Subject: [PATCH 09/14] Change function name --- test/Github/Tests/Api/GraphQLTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Github/Tests/Api/GraphQLTest.php b/test/Github/Tests/Api/GraphQLTest.php index 37840a60cc7..40968c1a30b 100644 --- a/test/Github/Tests/Api/GraphQLTest.php +++ b/test/Github/Tests/Api/GraphQLTest.php @@ -14,7 +14,7 @@ public function shouldShowGistComment() ->with('/graphql', 'bar') ->will($this->returnValue('foo')); - $result = $api->graphql('bar'); + $result = $api->execute('bar'); $this->assertEquals('foo', $result); } From 0be9dc1995611e56cc03327215b0784fe7fb196a Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Thu, 26 Jan 2017 10:08:54 +0100 Subject: [PATCH 10/14] Whitespace --- lib/Github/Api/GraphQL.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Github/Api/GraphQL.php b/lib/Github/Api/GraphQL.php index 59fef2827bd..90974015463 100644 --- a/lib/Github/Api/GraphQL.php +++ b/lib/Github/Api/GraphQL.php @@ -6,6 +6,7 @@ * GraphQL API. * * Part of the Github API Early-Access Program + * * @link https://developer.github.com/early-access/graphql/ * @author Miguel Piedrafita */ From 222e7755aa1db0c0813ccf7488456df3d432c0f6 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Thu, 26 Jan 2017 10:10:35 +0100 Subject: [PATCH 11/14] Updates --- test/Github/Tests/Api/GraphQLTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/Github/Tests/Api/GraphQLTest.php b/test/Github/Tests/Api/GraphQLTest.php index 40968c1a30b..ed57b408a1d 100644 --- a/test/Github/Tests/Api/GraphQLTest.php +++ b/test/Github/Tests/Api/GraphQLTest.php @@ -1,11 +1,13 @@ +getApiMock(); From 9f309889342d846d630e16253e71a207e4b6954a Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Thu, 26 Jan 2017 10:12:07 +0100 Subject: [PATCH 12/14] Add Namespace --- test/Github/Tests/Api/GraphQLTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Github/Tests/Api/GraphQLTest.php b/test/Github/Tests/Api/GraphQLTest.php index ed57b408a1d..ebd9bf2bd40 100644 --- a/test/Github/Tests/Api/GraphQLTest.php +++ b/test/Github/Tests/Api/GraphQLTest.php @@ -1,5 +1,7 @@ Date: Thu, 26 Jan 2017 10:13:12 +0100 Subject: [PATCH 13/14] Format --- test/Github/Tests/Api/GraphQLTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Github/Tests/Api/GraphQLTest.php b/test/Github/Tests/Api/GraphQLTest.php index ebd9bf2bd40..c05de99fb25 100644 --- a/test/Github/Tests/Api/GraphQLTest.php +++ b/test/Github/Tests/Api/GraphQLTest.php @@ -4,11 +4,11 @@ class GraphQLTest extends TestCase { - // GraphQL Tests /** * @test */ + public function shouldTestGraphQL() { $api = $this->getApiMock(); From 21138e65b8cd9db717fad2736d76c17f9e2a0e95 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Thu, 26 Jan 2017 10:50:54 +0100 Subject: [PATCH 14/14] Fix Tests --- test/Github/Tests/Api/GraphQLTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/Github/Tests/Api/GraphQLTest.php b/test/Github/Tests/Api/GraphQLTest.php index c05de99fb25..c209a733b75 100644 --- a/test/Github/Tests/Api/GraphQLTest.php +++ b/test/Github/Tests/Api/GraphQLTest.php @@ -8,14 +8,13 @@ class GraphQLTest extends TestCase /** * @test */ - public function shouldTestGraphQL() { $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('/graphql', 'bar') + ->with($this->equalTo('/graphql'), $this->equalTo(['query'=>'bar'])) ->will($this->returnValue('foo')); $result = $api->execute('bar');