forked from nuwave/lighthouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add artisan command
lighthouse:cache
to compile GraphQL AST (nuwave…
- Loading branch information
1 parent
1b8169d
commit bc04164
Showing
5 changed files
with
59 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
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,33 @@ | ||
<?php | ||
|
||
namespace Nuwave\Lighthouse\Console; | ||
|
||
use Illuminate\Console\Command; | ||
use Nuwave\Lighthouse\Schema\AST\ASTBuilder; | ||
|
||
class CacheCommand extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'lighthouse:cache'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Compile the GraphQL AST cache.'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle(ASTBuilder $builder): void | ||
{ | ||
$builder->documentAST(); | ||
|
||
$this->info('GraphQL AST schema cache created.'); | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace Tests\Unit\Console; | ||
|
||
use Nuwave\Lighthouse\Console\CacheCommand; | ||
use Tests\TestCase; | ||
|
||
class CacheCommandTest extends TestCase | ||
{ | ||
public function testItCachesGraphQLAST(): void | ||
{ | ||
$key = config('lighthouse.cache.key'); | ||
config(['lighthouse.cache.ttl' => 60]); | ||
$this->commandTester(new CacheCommand)->execute([]); | ||
$this->assertTrue(cache()->has($key)); | ||
} | ||
} |