lastdragon-ru/graphql-printer
GraphQL printer for PHP: turns a GraphQL AST/document into well-formatted GraphQL text with configurable indentation and style. Useful for debugging, logging, code generation, and producing consistent query/schema output in Laravel or any PHP app.
graphql-php/graphql or webonyx/graphql-php.graphql-php/graphql’s getSchema()). No custom GraphQL server required.| Risk Area | Assessment | Mitigation |
|---|---|---|
| Schema Complexity | May struggle with extremely large schemas (e.g., >1000 types). | Implement chunked printing or streaming for scalability. |
| Customization Overhead | Excessive config for simple use cases (e.g., basic schema dump). | Provide presets (e.g., compact, verbose) in Laravel service provider. |
| Dependency Conflicts | Minimal risk (no hard dependencies), but may conflict with graphql-php versions. |
Pin graphql-php/graphql version in composer.json. |
| Performance | Introspection can be slow for monolithic schemas. | Cache introspection results (e.g., Redis) or run during off-peak hours. |
graphql-php/graphql (v14+) or webonyx/graphql-php.php artisan graphql:print).app('graphql-printer')->printSchema()).config/graphql-printer.php) for customization.graphql:schema:dump) with presets.// app/Console/Commands/GraphQLSchemaDump.php
use LastDragon\GraphQLPrinter\Printer;
class GraphQLSchemaDump extends Command {
protected $signature = 'graphql:schema:dump {--type= : Filter by type}';
public function handle(Printer $printer) {
$schema = app('graphql')->getSchema();
$this->info($printer->printSchema($schema, ['type' => $this->option('type')]));
}
}
main branch pushes.- name: Generate GraphQL Schema Docs
run: php artisan graphql:schema:dump --type=Query > docs/schema.md
graphql-php/graphql, nWink/laravel-graphql).$printer->printSchema($schema, ['format' => 'markdown']);
php artisan graphql:print).graphql-php.graphql-inspector (alternative).--type flag to isolate issues (e.g., php artisan graphql:print --type=Mutation).--cache flag to store introspection results temporarily.Query, Mutation, Input).graphql-inspector for schema analysis.| Failure Scenario | Impact | Recovery |
|---|---|---|
| Introspection Disabled | Package fails silently. | Add fallback (e.g., log error + exit code). |
| Schema Changes Break Output | Docs become outdated. | Automate schema versioning in output (e.g., // Generated: 2023-11-15). |
| Performance Degradation | Slow CLI commands. | Cache introspection results or rate-limit usage. |
# Basic usage
php artisan graphql:print
# Filter by type
php artisan graphql:print --type=User
# Exclude directives
php artisan graphql:print --exclude-directives
How can I help you explore Laravel packages today?