From cd0c743e1308130f47df042746cbced5bb550592 Mon Sep 17 00:00:00 2001
From: Erik Van Kelst <4levels@gmail.com>
Date: Thu, 15 Mar 2018 13:16:25 +0100
Subject: [PATCH 1/6] Refactored visibility of type(), args() and field()
functions Updated Console commands to use Illuminate\Console\GeneratorCommand
---
src/Folklore/GraphQL/Relay/ConnectionEdgeType.php | 2 +-
src/Folklore/GraphQL/Relay/Console/ConnectionMakeCommand.php | 2 +-
src/Folklore/GraphQL/Relay/Console/InputMakeCommand.php | 2 +-
src/Folklore/GraphQL/Relay/Console/MutationMakeCommand.php | 2 +-
src/Folklore/GraphQL/Relay/Console/NodeMakeCommand.php | 2 +-
src/Folklore/GraphQL/Relay/Console/PayloadMakeCommand.php | 2 +-
src/Folklore/GraphQL/Relay/Console/stubs/input.stub | 2 +-
src/Folklore/GraphQL/Relay/Console/stubs/mutation.stub | 2 +-
src/Folklore/GraphQL/Relay/Console/stubs/node.stub | 2 +-
src/Folklore/GraphQL/Relay/Console/stubs/payload.stub | 2 +-
src/Folklore/GraphQL/Relay/NodeIdField.php | 2 +-
src/Folklore/GraphQL/Relay/NodeInterface.php | 2 +-
src/Folklore/GraphQL/Relay/NodeQuery.php | 4 ++--
src/Folklore/GraphQL/Relay/PageInfoType.php | 2 +-
src/Folklore/GraphQL/Relay/Support/ConnectionType.php | 2 +-
src/Folklore/GraphQL/Relay/Support/Mutation.php | 2 +-
16 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/Folklore/GraphQL/Relay/ConnectionEdgeType.php b/src/Folklore/GraphQL/Relay/ConnectionEdgeType.php
index 6fb72531..70eb0bc3 100644
--- a/src/Folklore/GraphQL/Relay/ConnectionEdgeType.php
+++ b/src/Folklore/GraphQL/Relay/ConnectionEdgeType.php
@@ -7,7 +7,7 @@
class ConnectionEdgeType extends BaseType
{
- protected function fields()
+ public function fields()
{
return [
'cursor' => [
diff --git a/src/Folklore/GraphQL/Relay/Console/ConnectionMakeCommand.php b/src/Folklore/GraphQL/Relay/Console/ConnectionMakeCommand.php
index cd26dfdf..eacb844b 100644
--- a/src/Folklore/GraphQL/Relay/Console/ConnectionMakeCommand.php
+++ b/src/Folklore/GraphQL/Relay/Console/ConnectionMakeCommand.php
@@ -2,7 +2,7 @@
namespace Folklore\GraphQL\Relay\Console;
-use Folklore\GraphQL\Console\GeneratorCommand;
+use Illuminate\Console\GeneratorCommand;
class ConnectionMakeCommand extends GeneratorCommand
{
diff --git a/src/Folklore/GraphQL/Relay/Console/InputMakeCommand.php b/src/Folklore/GraphQL/Relay/Console/InputMakeCommand.php
index 76537d31..00ac452b 100644
--- a/src/Folklore/GraphQL/Relay/Console/InputMakeCommand.php
+++ b/src/Folklore/GraphQL/Relay/Console/InputMakeCommand.php
@@ -2,7 +2,7 @@
namespace Folklore\GraphQL\Relay\Console;
-use Folklore\GraphQL\Console\GeneratorCommand;
+use Illuminate\Console\GeneratorCommand;
class InputMakeCommand extends GeneratorCommand
{
diff --git a/src/Folklore/GraphQL/Relay/Console/MutationMakeCommand.php b/src/Folklore/GraphQL/Relay/Console/MutationMakeCommand.php
index 62a97014..8d55d822 100644
--- a/src/Folklore/GraphQL/Relay/Console/MutationMakeCommand.php
+++ b/src/Folklore/GraphQL/Relay/Console/MutationMakeCommand.php
@@ -2,7 +2,7 @@
namespace Folklore\GraphQL\Relay\Console;
-use Folklore\GraphQL\Console\GeneratorCommand;
+use Illuminate\Console\GeneratorCommand;
class MutationMakeCommand extends GeneratorCommand
{
diff --git a/src/Folklore/GraphQL/Relay/Console/NodeMakeCommand.php b/src/Folklore/GraphQL/Relay/Console/NodeMakeCommand.php
index 06a5f193..98b14a9b 100644
--- a/src/Folklore/GraphQL/Relay/Console/NodeMakeCommand.php
+++ b/src/Folklore/GraphQL/Relay/Console/NodeMakeCommand.php
@@ -2,7 +2,7 @@
namespace Folklore\GraphQL\Relay\Console;
-use Folklore\GraphQL\Console\GeneratorCommand;
+use Illuminate\Console\GeneratorCommand;
class NodeMakeCommand extends GeneratorCommand
{
diff --git a/src/Folklore/GraphQL/Relay/Console/PayloadMakeCommand.php b/src/Folklore/GraphQL/Relay/Console/PayloadMakeCommand.php
index af692705..52f8fc94 100644
--- a/src/Folklore/GraphQL/Relay/Console/PayloadMakeCommand.php
+++ b/src/Folklore/GraphQL/Relay/Console/PayloadMakeCommand.php
@@ -2,7 +2,7 @@
namespace Folklore\GraphQL\Relay\Console;
-use Folklore\GraphQL\Console\GeneratorCommand;
+use Illuminate\Console\GeneratorCommand;
class PayloadMakeCommand extends GeneratorCommand
{
diff --git a/src/Folklore/GraphQL/Relay/Console/stubs/input.stub b/src/Folklore/GraphQL/Relay/Console/stubs/input.stub
index 2fe737d8..0de8b90f 100644
--- a/src/Folklore/GraphQL/Relay/Console/stubs/input.stub
+++ b/src/Folklore/GraphQL/Relay/Console/stubs/input.stub
@@ -13,7 +13,7 @@ class DummyClass extends BaseInputType
'description' => 'A relay mutation input type'
];
- protected function fields()
+ public function fields()
{
return [
diff --git a/src/Folklore/GraphQL/Relay/Console/stubs/mutation.stub b/src/Folklore/GraphQL/Relay/Console/stubs/mutation.stub
index 57400165..a0276078 100644
--- a/src/Folklore/GraphQL/Relay/Console/stubs/mutation.stub
+++ b/src/Folklore/GraphQL/Relay/Console/stubs/mutation.stub
@@ -18,7 +18,7 @@ class DummyClass extends BaseMutation
return null;
}
- protected function type()
+ public function type()
{
return null;
}
diff --git a/src/Folklore/GraphQL/Relay/Console/stubs/node.stub b/src/Folklore/GraphQL/Relay/Console/stubs/node.stub
index fdd533ac..1dfce5c7 100644
--- a/src/Folklore/GraphQL/Relay/Console/stubs/node.stub
+++ b/src/Folklore/GraphQL/Relay/Console/stubs/node.stub
@@ -13,7 +13,7 @@ class DummyClass extends BaseNodeType
'description' => 'A relay node type'
];
- protected function fields()
+ public function fields()
{
return [
'id' => [
diff --git a/src/Folklore/GraphQL/Relay/Console/stubs/payload.stub b/src/Folklore/GraphQL/Relay/Console/stubs/payload.stub
index 9f4a1e5d..d98d7dc2 100644
--- a/src/Folklore/GraphQL/Relay/Console/stubs/payload.stub
+++ b/src/Folklore/GraphQL/Relay/Console/stubs/payload.stub
@@ -13,7 +13,7 @@ class DummyClass extends BasePayloadType
'description' => 'A relay mutation payload type'
];
- protected function fields()
+ public function fields()
{
return [
diff --git a/src/Folklore/GraphQL/Relay/NodeIdField.php b/src/Folklore/GraphQL/Relay/NodeIdField.php
index a7c2c197..aeda542b 100644
--- a/src/Folklore/GraphQL/Relay/NodeIdField.php
+++ b/src/Folklore/GraphQL/Relay/NodeIdField.php
@@ -14,7 +14,7 @@ class NodeIdField extends BaseField
'description' => 'A relay node id field'
];
- protected function type()
+ public function type()
{
return Type::nonNull(Type::id());
}
diff --git a/src/Folklore/GraphQL/Relay/NodeInterface.php b/src/Folklore/GraphQL/Relay/NodeInterface.php
index b940bb6a..f602ee16 100644
--- a/src/Folklore/GraphQL/Relay/NodeInterface.php
+++ b/src/Folklore/GraphQL/Relay/NodeInterface.php
@@ -13,7 +13,7 @@ class NodeInterface extends BaseInterfaceType
'description' => 'The relay node interface'
];
- protected function fields()
+ public function fields()
{
return [
'id' => [
diff --git a/src/Folklore/GraphQL/Relay/NodeQuery.php b/src/Folklore/GraphQL/Relay/NodeQuery.php
index 37416573..cc769e04 100644
--- a/src/Folklore/GraphQL/Relay/NodeQuery.php
+++ b/src/Folklore/GraphQL/Relay/NodeQuery.php
@@ -17,12 +17,12 @@ class NodeQuery extends Query
'description' => 'A query'
];
- protected function type()
+ public function type()
{
return app('graphql')->type('Node');
}
- protected function args()
+ public function args()
{
return [
'id' => [
diff --git a/src/Folklore/GraphQL/Relay/PageInfoType.php b/src/Folklore/GraphQL/Relay/PageInfoType.php
index 3be7a130..9f490ed4 100644
--- a/src/Folklore/GraphQL/Relay/PageInfoType.php
+++ b/src/Folklore/GraphQL/Relay/PageInfoType.php
@@ -13,7 +13,7 @@ class PageInfoType extends BaseType
'description' => 'The relay pageInfo type used by connections'
];
- protected function fields()
+ public function fields()
{
return [
'hasNextPage' => [
diff --git a/src/Folklore/GraphQL/Relay/Support/ConnectionType.php b/src/Folklore/GraphQL/Relay/Support/ConnectionType.php
index 79a90af1..e4362aa2 100644
--- a/src/Folklore/GraphQL/Relay/Support/ConnectionType.php
+++ b/src/Folklore/GraphQL/Relay/Support/ConnectionType.php
@@ -19,7 +19,7 @@ protected function edgeType()
return null;
}
- protected function fields()
+ public function fields()
{
return [
'total' => [
diff --git a/src/Folklore/GraphQL/Relay/Support/Mutation.php b/src/Folklore/GraphQL/Relay/Support/Mutation.php
index 3498546a..2619ec81 100644
--- a/src/Folklore/GraphQL/Relay/Support/Mutation.php
+++ b/src/Folklore/GraphQL/Relay/Support/Mutation.php
@@ -25,7 +25,7 @@ public function setInputType($inputType)
$this->inputType = $inputType;
}
- protected function args()
+ public function args()
{
return [
'input' => [
From 6a478d92405aa4c201217316bc1c51a1b4dfb01a Mon Sep 17 00:00:00 2001
From: Erik Van Kelst <4levels@gmail.com>
Date: Thu, 15 Mar 2018 13:20:14 +0100
Subject: [PATCH 2/6] Fixed $limit being 0 when not set, resulting in empty
result set
---
.../Relay/Support/Traits/ResolvesFromQueryBuilder.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/Folklore/GraphQL/Relay/Support/Traits/ResolvesFromQueryBuilder.php b/src/Folklore/GraphQL/Relay/Support/Traits/ResolvesFromQueryBuilder.php
index 2b61b5b8..699c6dd7 100644
--- a/src/Folklore/GraphQL/Relay/Support/Traits/ResolvesFromQueryBuilder.php
+++ b/src/Folklore/GraphQL/Relay/Support/Traits/ResolvesFromQueryBuilder.php
@@ -137,7 +137,12 @@ public function resolve($root, $args)
$offset = max(0, $offset);
$limit = min($count - $offset, $limit);
- $query->skip($offset)->take($limit);
+ if ($offset) {
+ $query->skip($offset);
+ }
+ if ($limit) {
+ $query->take($limit);
+ }
$hasNextPage = ($offset + $limit) < $count;
$hasPreviousPage = $offset > 0;
From 8e97d8e0b57328d27059000c8036ff570a40c481 Mon Sep 17 00:00:00 2001
From: Erik Van Kelst <4levels@gmail.com>
Date: Mon, 19 Mar 2018 02:04:48 +0100
Subject: [PATCH 3/6] Added fix of @kikoseijo for updated routing in Lumen
---
src/Folklore/GraphQL/LumenServiceProvider.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Folklore/GraphQL/LumenServiceProvider.php b/src/Folklore/GraphQL/LumenServiceProvider.php
index c0cad515..505f736b 100644
--- a/src/Folklore/GraphQL/LumenServiceProvider.php
+++ b/src/Folklore/GraphQL/LumenServiceProvider.php
@@ -9,7 +9,7 @@ class LumenServiceProvider extends ServiceProvider
*/
protected function getRouter()
{
- return $this->app;
+ return property_exists($this->app, 'router') ? $this->app->router : $this->app;
}
/**
From 454a84fd1ba5cb8a6c3dded08d3ce0c92b5232f9 Mon Sep 17 00:00:00 2001
From: Erik Van Kelst <4levels@gmail.com>
Date: Mon, 19 Mar 2018 14:28:07 +0100
Subject: [PATCH 4/6] Allowed Lumen/Laravel 5.6 dependencies
---
composer.json | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/composer.json b/composer.json
index 8565de66..350f0893 100644
--- a/composer.json
+++ b/composer.json
@@ -19,14 +19,14 @@
"type": "project",
"require": {
"php": ">=5.5.9",
- "illuminate/support": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*",
- "webonyx/graphql-php": "~0.10.2"
+ "illuminate/support": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*",
+ "webonyx/graphql-php": "~0.10|~0.11"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
- "orchestra/testbench": "3.1.*|3.2.*|3.3.*|3.4.*|3.5.*",
- "mockery/mockery": "0.9.*",
- "phpunit/phpunit": "~4.0|~5.0|~5.7|~6.0",
+ "orchestra/testbench": "3.1.*|3.2.*|3.3.*|3.4.*|3.5.*|3.6.*",
+ "mockery/mockery": "0.9.*|1.0.*",
+ "phpunit/phpunit": "~4.0|~5.0|~5.7|~6.0|~7.0",
"satooshi/php-coveralls": "^1.0"
},
"autoload": {
From ccaee976efcccba97e2b56c135ace783c8e51d46 Mon Sep 17 00:00:00 2001
From: Erik Van Kelst <4levels@gmail.com>
Date: Wed, 21 Mar 2018 00:30:12 +0100
Subject: [PATCH 5/6] Renamed file to work with GraphQL::introspection() work
---
.../graphql/{introspectionQuery.txt => introspection.txt} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename src/resources/graphql/{introspectionQuery.txt => introspection.txt} (100%)
diff --git a/src/resources/graphql/introspectionQuery.txt b/src/resources/graphql/introspection.txt
similarity index 100%
rename from src/resources/graphql/introspectionQuery.txt
rename to src/resources/graphql/introspection.txt
From 416242e09c9d0c34e76a4db924b8159f0a10c47f Mon Sep 17 00:00:00 2001
From: Erik Van Kelst <4levels@gmail.com>
Date: Wed, 21 Mar 2018 10:12:51 +0100
Subject: [PATCH 6/6] Removed use of Facades in SchemaCommand
---
src/Folklore/GraphQL/Console/SchemaCommand.php | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/Folklore/GraphQL/Console/SchemaCommand.php b/src/Folklore/GraphQL/Console/SchemaCommand.php
index 53006e3e..9e2036bc 100644
--- a/src/Folklore/GraphQL/Console/SchemaCommand.php
+++ b/src/Folklore/GraphQL/Console/SchemaCommand.php
@@ -4,7 +4,6 @@
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
-use GraphQL;
class SchemaCommand extends Command
{
@@ -24,7 +23,7 @@ class SchemaCommand extends Command
* @var string
*/
protected $description = 'Generate a graphql schema';
-
+
/**
* Filesystem instance for fs operations
*
@@ -35,7 +34,7 @@ class SchemaCommand extends Command
public function __construct(Filesystem $files)
{
parent::__construct();
-
+
$this->files = $files;
}
@@ -50,15 +49,15 @@ public function handle()
if (empty($schema)) {
$schema = config('graphql.schema');
}
-
- $return = GraphQL::introspection($schema);
+
+ $return = app('graphql')->introspection($schema);
$json = json_encode($return, JSON_PRETTY_PRINT);
-
+
if ($this->option('output')) {
echo $json;
return;
}
-
+
$defaultPath = config('graphql.introspection.schema_output', base_path('resources/graphql/schema.json'));
$path = $this->option('path') ? $this->option('path'):$defaultPath;
$dirname = dirname($path);
@@ -66,7 +65,7 @@ public function handle()
$this->files->makeDirectory($dirname, 0775, true);
$this->line('Created: Parent directory '.$dirname);
}
-
+
$this->files->put($path, $json);
$this->line('Created: Schema at '.$path);
}