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

Commit 11ef6fb

Browse files
authored
Merge pull request #216 from 4levels/feature/relay
Removed dependency on Facades
2 parents ae0b3bc + 87cdfb2 commit 11ef6fb

File tree

7 files changed

+12
-21
lines changed

7 files changed

+12
-21
lines changed

src/Folklore/GraphQL/LumenServiceProvider.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php namespace Folklore\GraphQL;
22

3-
use Illuminate\Support\Facades\Facade;
4-
53
class LumenServiceProvider extends ServiceProvider
64
{
75
/**

src/Folklore/GraphQL/Relay/ConnectionEdgeType.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use GraphQL\Type\Definition\Type;
66
use Folklore\GraphQL\Support\Type as BaseType;
7-
use GraphQL;
87

98
class ConnectionEdgeType extends BaseType
109
{
@@ -15,7 +14,7 @@ protected function fields()
1514
'type' => Type::nonNull(Type::id())
1615
],
1716
'node' => [
18-
'type' => GraphQL::type('Node')
17+
'type' => app('graphql')->type('Node')
1918
]
2019
];
2120
}

src/Folklore/GraphQL/Relay/NodeIdField.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use GraphQL\Type\Definition\Type;
66
use Folklore\GraphQL\Support\Field as BaseField;
7-
use Relay as RelayFacade;
87

98
class NodeIdField extends BaseField
109
{
@@ -45,6 +44,6 @@ public function getIdType()
4544
public function resolve()
4645
{
4746
$id = call_user_func_array($this->idResolver, func_get_args());
48-
return RelayFacade::toGlobalId($this->idType, $id);
47+
return app('graphql.relay')->toGlobalId($this->idType, $id);
4948
}
5049
}

src/Folklore/GraphQL/Relay/NodeQuery.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
use Folklore\GraphQL\Support\Query;
66
use GraphQL\Type\Definition\ResolveInfo;
77
use GraphQL\Type\Definition\Type;
8-
use GraphQL;
9-
use Relay as RelayFacade;
108
use Folklore\GraphQL\Exception\TypeNotFound;
119
use Folklore\GraphQL\Relay\Exception\NodeInvalid;
1210

@@ -21,7 +19,7 @@ class NodeQuery extends Query
2119

2220
protected function type()
2321
{
24-
return GraphQL::type('Node');
22+
return app('graphql')->type('Node');
2523
}
2624

2725
protected function args()
@@ -36,10 +34,10 @@ protected function args()
3634

3735
public function resolve($root, $args, $context, ResolveInfo $info)
3836
{
39-
$globalId = RelayFacade::fromGlobalId($args['id']);
37+
$globalId = app('graphql.relay')->fromGlobalId($args['id']);
4038
$typeName = $globalId['type'];
4139
$id = $globalId['id'];
42-
$types = GraphQL::getTypes();
40+
$types = app('graphql')->getTypes();
4341
$typeClass = array_get($types, $typeName);
4442

4543
if (!$typeClass) {
@@ -56,7 +54,7 @@ public function resolve($root, $args, $context, ResolveInfo $info)
5654

5755
$response = new NodeResponse();
5856
$response->setNode($node);
59-
$response->setType(GraphQL::type($typeName));
57+
$response->setType(app('graphql')->type($typeName));
6058

6159
return $response;
6260
}

src/Folklore/GraphQL/Relay/Relay.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Folklore\GraphQL\Relay\Support\ConnectionField;
66
use Folklore\GraphQL\Relay\Support\ConnectionType;
7-
use GraphQL;
87

98
class Relay
109
{
@@ -32,11 +31,11 @@ public function connectionFieldFromEdgeType($edgeType, $config = [])
3231
'name' => $connectionName
3332
]);
3433
$connectionType->setEdgeType($edgeType);
35-
GraphQL::addType($connectionType, $connectionName);
34+
$this->graphql->addType($connectionType, $connectionName);
3635

3736
$fieldConfig = array_except($config, ['connectionTypeName']);
3837
$field = new ConnectionField($fieldConfig);
39-
$field->setType(GraphQL::type($connectionName));
38+
$field->setType($this->graphql->type($connectionName));
4039
return $field;
4140
}
4241

src/Folklore/GraphQL/Relay/Support/ConnectionType.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use GraphQL\Type\Definition\Type;
66
use GraphQL\Type\Definition\InterfaceType;
77
use Folklore\GraphQL\Support\Type as BaseType;
8-
use GraphQL;
98

109
use Folklore\GraphQL\Relay\EdgesCollection;
1110
use Illuminate\Pagination\AbstractPaginator;
@@ -36,7 +35,7 @@ protected function fields()
3635
}
3736
],
3837
'pageInfo' => [
39-
'type' => GraphQL::type('PageInfo'),
38+
'type' => app('graphql')->type('PageInfo'),
4039
'resolve' => function ($root) {
4140
return $this->getPageInfoFromRoot($root);
4241
}
@@ -60,8 +59,8 @@ protected function getEdgeObjectType()
6059
{
6160
$edgeType = $this->getEdgeType();
6261
$name = $edgeType->config['name'].'Edge';
63-
GraphQL::addType(\Folklore\GraphQL\Relay\ConnectionEdgeType::class, $name);
64-
$type = GraphQL::type($name);
62+
app('graphql')->addType(\Folklore\GraphQL\Relay\ConnectionEdgeType::class, $name);
63+
$type = app('graphql')->type($name);
6564
$type->setEdgeType($edgeType);
6665
return $type;
6766
}

src/Folklore/GraphQL/Relay/Support/Traits/TypeIsNode.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Folklore\GraphQL\Relay\Support\Traits;
44

5-
use GraphQL;
65
use Folklore\GraphQL\Relay\NodeIdField;
76

87
trait TypeIsNode
@@ -47,7 +46,7 @@ protected function getIdResolverFromFields($fields)
4746
protected function relayInterfaces()
4847
{
4948
return [
50-
GraphQL::type('Node')
49+
app('graphql')->type('Node')
5150
];
5251
}
5352

0 commit comments

Comments
 (0)