Weave 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
Phpunit Graphql

Phpunit Graphql Laravel Package

lastdragon-ru/phpunit-graphql

PHPUnit helpers for testing GraphQL in PHP apps. Provides assertions and utilities to execute queries/mutations, validate responses, and compare errors/data structures, aimed at simplifying reliable GraphQL API test coverage.

Deep Wiki
Context7

Useful assertions for PHPUnit to check printed/exported type/queries with lastdragon-ru/graphql-printer package.

Frequently asked questions about Phpunit Graphql
How do I install this package for Laravel GraphQL testing?
Run `composer require lastdragon-ru/phpunit-graphql` and ensure `lastdragon-ru/graphql-printer` is installed. The package integrates directly with PHPUnit, so no additional Laravel configuration is needed beyond your existing test setup.
Does this package work with Laravel’s built-in PHPUnit?
Yes, it’s fully compatible with Laravel’s PHPUnit integration. You can use it alongside Laravel’s testing helpers like `actingAs()` or `refreshDatabase()` in your GraphQL test cases.
Which Laravel GraphQL packages does this support (e.g., webonyx/graphql-php, filamentphp/graphql)?
This package works with any PHP GraphQL implementation that uses `lastdragon-ru/graphql-printer` for output formatting. If your Laravel app uses a different printer (e.g., webonyx’s default), you may need to adapt or switch printers.
Can I test GraphQL mutations and subscriptions with this package?
Yes, the assertions support mutations and subscriptions, but you’ll need to structure your test cases to match the printer’s output format. For subscriptions, ensure your test environment can handle real-time responses.
What happens if my GraphQL schema evolves (e.g., new fields or deprecations)?
Assertions tied to specific schema structures may need updates. Test critical queries early and refactor assertions incrementally to match schema changes. The package doesn’t lock you into a schema version.
Is there a performance impact when running these assertions in CI/CD?
The package adds minimal overhead since it focuses on parsing and validating printer output. For large schemas, ensure your CI environment has sufficient resources, but it should not significantly slow down test execution.
How do I handle errors or invalid responses in GraphQL tests?
The package provides utilities to validate error structures, including error messages and codes. Use assertions like `assertGraphQLErrorMatches()` to verify expected failures in queries or mutations.
What if I don’t want to use `lastdragon-ru/graphql-printer`? Are there alternatives?
This package is designed to work with `graphql-printer`. If you’re using a different printer (e.g., webonyx’s default), you’ll need to either switch printers or create custom assertion wrappers to match your output format.
Can I extend or customize the assertions for my Laravel app?
Yes, the package is designed for extensibility. You can create custom assertion methods or wrappers to handle edge cases, such as validating complex fragments or directives specific to your GraphQL schema.
What Laravel and PHPUnit versions does this package support?
The package aligns with Laravel’s PHPUnit version (typically ^9.5 or ^10.0). Check the package’s `composer.json` for exact requirements, but it should work seamlessly with modern Laravel setups using PHPUnit.
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.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels