-
-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace Nuwave\Lighthouse\Support\Console\Commands; | ||
|
||
use Illuminate\Console\GeneratorCommand; | ||
|
||
class EdgeMakeCommand extends GeneratorCommand | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'lighthouse:edge'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Generate a Relay connection.'; | ||
|
||
/** | ||
* The type of class being generated. | ||
* | ||
* @var string | ||
*/ | ||
protected $type = 'Edge'; | ||
|
||
/** | ||
* Get the stub file for the generator. | ||
* | ||
* @return string | ||
*/ | ||
protected function getStub() | ||
{ | ||
return __DIR__.'/stubs/relay_edge.stub'; | ||
} | ||
|
||
/** | ||
* Get the default namespace for the class. | ||
* | ||
* @param string $rootNamespace | ||
* @return string | ||
*/ | ||
protected function getDefaultNamespace($rootNamespace) | ||
{ | ||
return config('lighthouse.namespaces.edges'); | ||
} | ||
|
||
/** | ||
* Get the console command options. | ||
* | ||
* @return array | ||
*/ | ||
protected function getOptions() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* Replace the class name for the given stub. | ||
* | ||
* @param string $stub | ||
* @param string $name | ||
* @return string | ||
*/ | ||
protected function replaceClass($stub, $name) | ||
{ | ||
$class = str_replace($this->getNamespace($name).'\\', '', $name); | ||
|
||
return str_replace('DummyClass', $class, $stub); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace DummyNamespace; | ||
|
||
use Nuwave\Lighthouse\Support\Interfaces\ConnectionEdge; | ||
|
||
class DummyClass implements ConnectionEdge | ||
{ | ||
/** | ||
* Name of edge. | ||
* | ||
* @return string | ||
*/ | ||
public function name() | ||
{ | ||
return ''; | ||
} | ||
|
||
/** | ||
* Name of type edge resolves. | ||
* | ||
* @return string | ||
*/ | ||
public function type() | ||
{ | ||
return ''; | ||
} | ||
|
||
/** | ||
* Extract edge from payload. | ||
* | ||
* @param mixed $payload | ||
* @return mixed | ||
*/ | ||
public function edge($payload) | ||
{ | ||
// return $payload['']; | ||
} | ||
|
||
/** | ||
* Resolve cursor. | ||
* | ||
* @param mixed $payload | ||
* @return mixed | ||
*/ | ||
public function cursor($payload) | ||
{ | ||
// TODO: Resolve cursor | ||
} | ||
} |