Skip to content
This repository was archived by the owner on Feb 10, 2019. It is now read-only.

Fixes visibility issues and query resolver limit #306

Open
wants to merge 6 commits into
base: feature/relay
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
15 changes: 7 additions & 8 deletions src/Folklore/GraphQL/Console/SchemaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use GraphQL;

class SchemaCommand extends Command
{
Expand All @@ -24,7 +23,7 @@ class SchemaCommand extends Command
* @var string
*/
protected $description = 'Generate a graphql schema';

/**
* Filesystem instance for fs operations
*
Expand All @@ -35,7 +34,7 @@ class SchemaCommand extends Command
public function __construct(Filesystem $files)
{
parent::__construct();

$this->files = $files;
}

Expand All @@ -50,23 +49,23 @@ 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);
if (!$this->files->isDirectory($dirname)) {
$this->files->makeDirectory($dirname, 0775, true);
$this->line('<info>Created:</info> Parent directory '.$dirname);
}

$this->files->put($path, $json);
$this->line('<info>Created:</info> Schema at '.$path);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Folklore/GraphQL/LumenServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Folklore/GraphQL/Relay/ConnectionEdgeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class ConnectionEdgeType extends BaseType
{
protected function fields()
public function fields()
{
return [
'cursor' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Folklore\GraphQL\Relay\Console;

use Folklore\GraphQL\Console\GeneratorCommand;
use Illuminate\Console\GeneratorCommand;

class ConnectionMakeCommand extends GeneratorCommand
{
Expand Down
2 changes: 1 addition & 1 deletion src/Folklore/GraphQL/Relay/Console/InputMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Folklore\GraphQL\Relay\Console;

use Folklore\GraphQL\Console\GeneratorCommand;
use Illuminate\Console\GeneratorCommand;

class InputMakeCommand extends GeneratorCommand
{
Expand Down
2 changes: 1 addition & 1 deletion src/Folklore/GraphQL/Relay/Console/MutationMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Folklore\GraphQL\Relay\Console;

use Folklore\GraphQL\Console\GeneratorCommand;
use Illuminate\Console\GeneratorCommand;

class MutationMakeCommand extends GeneratorCommand
{
Expand Down
2 changes: 1 addition & 1 deletion src/Folklore/GraphQL/Relay/Console/NodeMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Folklore\GraphQL\Relay\Console;

use Folklore\GraphQL\Console\GeneratorCommand;
use Illuminate\Console\GeneratorCommand;

class NodeMakeCommand extends GeneratorCommand
{
Expand Down
2 changes: 1 addition & 1 deletion src/Folklore/GraphQL/Relay/Console/PayloadMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Folklore\GraphQL\Relay\Console;

use Folklore\GraphQL\Console\GeneratorCommand;
use Illuminate\Console\GeneratorCommand;

class PayloadMakeCommand extends GeneratorCommand
{
Expand Down
2 changes: 1 addition & 1 deletion src/Folklore/GraphQL/Relay/Console/stubs/input.stub
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DummyClass extends BaseInputType
'description' => 'A relay mutation input type'
];

protected function fields()
public function fields()
{
return [

Expand Down
2 changes: 1 addition & 1 deletion src/Folklore/GraphQL/Relay/Console/stubs/mutation.stub
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DummyClass extends BaseMutation
return null;
}

protected function type()
public function type()
{
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Folklore/GraphQL/Relay/Console/stubs/node.stub
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DummyClass extends BaseNodeType
'description' => 'A relay node type'
];

protected function fields()
public function fields()
{
return [
'id' => [
Expand Down
2 changes: 1 addition & 1 deletion src/Folklore/GraphQL/Relay/Console/stubs/payload.stub
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DummyClass extends BasePayloadType
'description' => 'A relay mutation payload type'
];

protected function fields()
public function fields()
{
return [

Expand Down
2 changes: 1 addition & 1 deletion src/Folklore/GraphQL/Relay/NodeIdField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Folklore/GraphQL/Relay/NodeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class NodeInterface extends BaseInterfaceType
'description' => 'The relay node interface'
];

protected function fields()
public function fields()
{
return [
'id' => [
Expand Down
4 changes: 2 additions & 2 deletions src/Folklore/GraphQL/Relay/NodeQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
2 changes: 1 addition & 1 deletion src/Folklore/GraphQL/Relay/PageInfoType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PageInfoType extends BaseType
'description' => 'The relay pageInfo type used by connections'
];

protected function fields()
public function fields()
{
return [
'hasNextPage' => [
Expand Down
2 changes: 1 addition & 1 deletion src/Folklore/GraphQL/Relay/Support/ConnectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected function edgeType()
return null;
}

protected function fields()
public function fields()
{
return [
'total' => [
Expand Down
2 changes: 1 addition & 1 deletion src/Folklore/GraphQL/Relay/Support/Mutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function setInputType($inputType)
$this->inputType = $inputType;
}

protected function args()
public function args()
{
return [
'input' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down