Commit 3abf3cb 1 parent 0f44dd6 commit 3abf3cb Copy full SHA for 3abf3cb
File tree 3 files changed +125
-0
lines changed
3 files changed +125
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ public function register()
48
48
Support \Console \Commands \QueryMakeCommand::class,
49
49
Support \Console \Commands \TypeMakeCommand::class,
50
50
Support \Console \Commands \ConnectionMakeCommand::class,
51
+ Support \Console \Commands \EdgeMakeCommand::class,
51
52
]);
52
53
53
54
$ this ->registerMacro ();
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Nuwave \Lighthouse \Support \Console \Commands ;
4
+
5
+ use Illuminate \Console \GeneratorCommand ;
6
+
7
+ class EdgeMakeCommand extends GeneratorCommand
8
+ {
9
+ /**
10
+ * The name and signature of the console command.
11
+ *
12
+ * @var string
13
+ */
14
+ protected $ name = 'lighthouse:edge ' ;
15
+
16
+ /**
17
+ * The console command description.
18
+ *
19
+ * @var string
20
+ */
21
+ protected $ description = 'Generate a Relay connection. ' ;
22
+
23
+ /**
24
+ * The type of class being generated.
25
+ *
26
+ * @var string
27
+ */
28
+ protected $ type = 'Edge ' ;
29
+
30
+ /**
31
+ * Get the stub file for the generator.
32
+ *
33
+ * @return string
34
+ */
35
+ protected function getStub ()
36
+ {
37
+ return __DIR__ .'/stubs/relay_edge.stub ' ;
38
+ }
39
+
40
+ /**
41
+ * Get the default namespace for the class.
42
+ *
43
+ * @param string $rootNamespace
44
+ * @return string
45
+ */
46
+ protected function getDefaultNamespace ($ rootNamespace )
47
+ {
48
+ return config ('lighthouse.namespaces.edges ' );
49
+ }
50
+
51
+ /**
52
+ * Get the console command options.
53
+ *
54
+ * @return array
55
+ */
56
+ protected function getOptions ()
57
+ {
58
+ return [];
59
+ }
60
+
61
+ /**
62
+ * Replace the class name for the given stub.
63
+ *
64
+ * @param string $stub
65
+ * @param string $name
66
+ * @return string
67
+ */
68
+ protected function replaceClass ($ stub , $ name )
69
+ {
70
+ $ class = str_replace ($ this ->getNamespace ($ name ).'\\' , '' , $ name );
71
+
72
+ return str_replace ('DummyClass ' , $ class , $ stub );
73
+ }
74
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace DummyNamespace;
4
+
5
+ use Nuwave\Lighthouse\Support\Interfaces\ConnectionEdge;
6
+
7
+ class DummyClass implements ConnectionEdge
8
+ {
9
+ /**
10
+ * Name of edge.
11
+ *
12
+ * @return string
13
+ */
14
+ public function name()
15
+ {
16
+ return '';
17
+ }
18
+
19
+ /**
20
+ * Name of type edge resolves.
21
+ *
22
+ * @return string
23
+ */
24
+ public function type()
25
+ {
26
+ return '';
27
+ }
28
+
29
+ /**
30
+ * Extract edge from payload.
31
+ *
32
+ * @param mixed $payload
33
+ * @return mixed
34
+ */
35
+ public function edge($payload)
36
+ {
37
+ // return $payload[''];
38
+ }
39
+
40
+ /**
41
+ * Resolve cursor.
42
+ *
43
+ * @param mixed $payload
44
+ * @return mixed
45
+ */
46
+ public function cursor($payload)
47
+ {
48
+ // TODO: Resolve cursor
49
+ }
50
+ }
You can’t perform that action at this time.
0 commit comments