Created
October 12, 2019 15:35
-
-
Save bsilva0x87/02379ec5c6634fd6ce2484bef2f90815 to your computer and use it in GitHub Desktop.
Simple implementation for command "lighthouse:print-schema" to compile the final GraphQL schema using Lighthouse / Lumen PHP.
This file contains hidden or 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
<?php | |
namespace Nuwave\Lighthouse\Console; | |
use Nuwave\Lighthouse\GraphQL; | |
use Illuminate\Console\Command; | |
use GraphQL\Utils\SchemaPrinter; | |
class PrintSchemaCommand extends Command | |
{ | |
/** | |
* The name and signature of the console command. | |
* | |
* @var string | |
*/ | |
protected $signature = ' | |
lighthouse:print-schema {--W|write : Write the output to a file} | |
'; | |
/** | |
* The console command description. | |
* | |
* @var string | |
*/ | |
protected $description = 'Compile the final GraphQL schema and print the result.'; | |
/** | |
* Execute the console command. | |
* | |
* @param \Nuwave\Lighthouse\GraphQL $graphQL | |
* @return void | |
*/ | |
public function handle(GraphQL $graphQL): void | |
{ | |
$schema = SchemaPrinter::doPrint($graphQL->prepSchema()); | |
file_put_contents('schema.graphql', $schema); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment