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

Removed dependency on Facades #216

Merged
merged 1 commit into from
Oct 5, 2017
Merged
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
2 changes: 0 additions & 2 deletions src/Folklore/GraphQL/LumenServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php namespace Folklore\GraphQL;

use Illuminate\Support\Facades\Facade;

class LumenServiceProvider extends ServiceProvider
{
/**
Expand Down
3 changes: 1 addition & 2 deletions src/Folklore/GraphQL/Relay/ConnectionEdgeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use GraphQL\Type\Definition\Type;
use Folklore\GraphQL\Support\Type as BaseType;
use GraphQL;

class ConnectionEdgeType extends BaseType
{
Expand All @@ -15,7 +14,7 @@ protected function fields()
'type' => Type::nonNull(Type::id())
],
'node' => [
'type' => GraphQL::type('Node')
'type' => app('graphql')->type('Node')
]
];
}
Expand Down
3 changes: 1 addition & 2 deletions src/Folklore/GraphQL/Relay/NodeIdField.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use GraphQL\Type\Definition\Type;
use Folklore\GraphQL\Support\Field as BaseField;
use Relay as RelayFacade;

class NodeIdField extends BaseField
{
Expand Down Expand Up @@ -45,6 +44,6 @@ public function getIdType()
public function resolve()
{
$id = call_user_func_array($this->idResolver, func_get_args());
return RelayFacade::toGlobalId($this->idType, $id);
return app('graphql.relay')->toGlobalId($this->idType, $id);
}
}
10 changes: 4 additions & 6 deletions src/Folklore/GraphQL/Relay/NodeQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
use Folklore\GraphQL\Support\Query;
use GraphQL\Type\Definition\ResolveInfo;
use GraphQL\Type\Definition\Type;
use GraphQL;
use Relay as RelayFacade;
use Folklore\GraphQL\Exception\TypeNotFound;
use Folklore\GraphQL\Relay\Exception\NodeInvalid;

Expand All @@ -21,7 +19,7 @@ class NodeQuery extends Query

protected function type()
{
return GraphQL::type('Node');
return app('graphql')->type('Node');
}

protected function args()
Expand All @@ -36,10 +34,10 @@ protected function args()

public function resolve($root, $args, $context, ResolveInfo $info)
{
$globalId = RelayFacade::fromGlobalId($args['id']);
$globalId = app('graphql.relay')->fromGlobalId($args['id']);
$typeName = $globalId['type'];
$id = $globalId['id'];
$types = GraphQL::getTypes();
$types = app('graphql')->getTypes();
$typeClass = array_get($types, $typeName);

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

$response = new NodeResponse();
$response->setNode($node);
$response->setType(GraphQL::type($typeName));
$response->setType(app('graphql')->type($typeName));

return $response;
}
Expand Down
5 changes: 2 additions & 3 deletions src/Folklore/GraphQL/Relay/Relay.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Folklore\GraphQL\Relay\Support\ConnectionField;
use Folklore\GraphQL\Relay\Support\ConnectionType;
use GraphQL;

class Relay
{
Expand Down Expand Up @@ -32,11 +31,11 @@ public function connectionFieldFromEdgeType($edgeType, $config = [])
'name' => $connectionName
]);
$connectionType->setEdgeType($edgeType);
GraphQL::addType($connectionType, $connectionName);
$this->graphql->addType($connectionType, $connectionName);

$fieldConfig = array_except($config, ['connectionTypeName']);
$field = new ConnectionField($fieldConfig);
$field->setType(GraphQL::type($connectionName));
$field->setType($this->graphql->type($connectionName));
return $field;
}

Expand Down
7 changes: 3 additions & 4 deletions src/Folklore/GraphQL/Relay/Support/ConnectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use GraphQL\Type\Definition\Type;
use GraphQL\Type\Definition\InterfaceType;
use Folklore\GraphQL\Support\Type as BaseType;
use GraphQL;

use Folklore\GraphQL\Relay\EdgesCollection;
use Illuminate\Pagination\AbstractPaginator;
Expand Down Expand Up @@ -36,7 +35,7 @@ protected function fields()
}
],
'pageInfo' => [
'type' => GraphQL::type('PageInfo'),
'type' => app('graphql')->type('PageInfo'),
'resolve' => function ($root) {
return $this->getPageInfoFromRoot($root);
}
Expand All @@ -60,8 +59,8 @@ protected function getEdgeObjectType()
{
$edgeType = $this->getEdgeType();
$name = $edgeType->config['name'].'Edge';
GraphQL::addType(\Folklore\GraphQL\Relay\ConnectionEdgeType::class, $name);
$type = GraphQL::type($name);
app('graphql')->addType(\Folklore\GraphQL\Relay\ConnectionEdgeType::class, $name);
$type = app('graphql')->type($name);
$type->setEdgeType($edgeType);
return $type;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Folklore/GraphQL/Relay/Support/Traits/TypeIsNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Folklore\GraphQL\Relay\Support\Traits;

use GraphQL;
use Folklore\GraphQL\Relay\NodeIdField;

trait TypeIsNode
Expand Down Expand Up @@ -47,7 +46,7 @@ protected function getIdResolverFromFields($fields)
protected function relayInterfaces()
{
return [
GraphQL::type('Node')
app('graphql')->type('Node')
];
}

Expand Down