Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Graphql Printer

Graphql Printer Laravel Package

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.

View on GitHub
Deep Wiki
Context7

The package allows you to print GraphQL Schema and Queries in a highly customized way eg you can choose indent size, print only used/wanted/all types, print only one type, print used/wanted/all directives and even check which types/directives are used in the Schema/Query.

Frequently asked questions about Graphql Printer
How do I install this package in a Laravel project?
Run `composer require lastdragon-ru/graphql-printer` in your project directory. The package supports PHP 8.0–8.5 and works with webonyx/graphql-php v14.11.9+ or v15.x. No additional Laravel-specific setup is required beyond Composer installation.
Can I use this to generate a filtered schema for frontend teams?
Yes. Use the `Printer::export()` method with options like `['types' => ['Query', 'User']]` to include only specific types. This reduces complexity for frontend developers while keeping the schema accurate. Combine with Laravel’s service container for easy access.
What’s the difference between `print()` and `export()` methods?
`print()` outputs a single type and its *direct* dependencies (e.g., fields, directives). `export()` includes *all* used types/directives recursively, ensuring a self-contained schema snippet. Use `export()` for standalone documentation and `print()` for debugging specific fragments.
Does this work with Laravel’s Artisan commands?
Absolutely. Wrap the printer in a custom Artisan command (e.g., `graphql:schema:dump`) to generate formatted output via CLI. Example: `php artisan graphql:schema:dump --type=User`. The package’s settings can be configured globally in a Laravel service provider.
How do I handle large schemas (e.g., 500+ types) without performance issues?
For large schemas, cache the introspection result (e.g., Redis) or use streaming output. The package itself doesn’t enforce limits, but you can optimize by filtering types/directives upfront (e.g., `['types' => ['Query', 'Mutation']]`). Test with your schema size in a staging environment first.
Can I integrate this with GraphiQL or other GraphQL tools?
Yes. Use the printer to generate a minimal schema snippet (e.g., for a specific query type) and embed it in GraphiQL’s docs or a Markdown file. The output is pure GraphQL text, so it’s compatible with any tool that accepts schema definitions.
What Laravel versions does this package support?
The package is framework-agnostic but works seamlessly with Laravel 8+. It relies on PHP’s Composer autoloading, so no Laravel-specific version constraints exist. Tested with Laravel 9+ and 10+ in production environments.
How do I check which directives/types are unused in my schema?
Use the `Printer::getUnusedTypes()` or `getUnusedDirectives()` methods (if available in your version) to analyze the schema. Alternatively, compare the full schema output with a filtered export (e.g., `export(['types' => ['Query']])`) to spot discrepancies manually.
Will this conflict with existing GraphQL packages like `webonyx/graphql-php`?
No. This package is a standalone printer and doesn’t modify your GraphQL server. It works alongside `webonyx/graphql-php` or `graphql-php/graphql` by consuming their schema objects. Pin your `graphql-php` version in `composer.json` to avoid dependency conflicts.
Can I use this for CI/CD schema validation (e.g., diffing changes)?
Yes. Generate schema snapshots in CI (e.g., GitHub Actions) using the printer’s CLI or programmatic output. Compare hashes or diff the text output against a baseline (e.g., `git diff`) to detect breaking changes. Example: `php artisan graphql:schema:dump > schema.graphql && git add schema.graphql`.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor