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 Php

Graphql Php Laravel Package

webonyx/graphql-php

Spec-compliant GraphQL server implementation for PHP, based on graphql-js. Build schemas, types, resolvers, validation and execution with full October 2021 spec support (Sept 2025 in progress). Foundation library used by many PHP frameworks.

View on GitHub
Deep Wiki
Context7

PHP implementation of the GraphQL specification based on the reference implementation in JavaScript

Frequently asked questions about Graphql Php
How do I integrate webonyx/graphql-php into a Laravel 9+ project?
Install via Composer: `composer require webonyx/graphql-php`. Register the GraphQL route in `routes/web.php` using `Route::graphql('/graphql', fn(Server $server) => $server->setSchema(new Schema()))`. Ensure your `Schema` class extends `GraphQL\Schema\Schema` and define types/resolvers. Laravel’s service container auto-resolves dependencies.
Does this package support Laravel’s middleware (e.g., auth, rate-limiting) for GraphQL?
Yes. Wrap the `StandardServer` in Laravel’s middleware pipeline by binding it to the container and using middleware groups. For example, add `graphql.auth` middleware to the `StandardServer` constructor or via route middleware. Auth context can be passed to resolvers via the `context` parameter.
What Laravel versions and PHP requirements does webonyx/graphql-php support?
The package requires PHP 7.4+ and works with Laravel 8+. For Laravel 5.5–7.x, use v14.x (last major version with PHP 7.2 support). Check the [changelog](https://github.com/webonyx/graphql-php/blob/master/CHANGELOG.md) for version-specific Laravel compatibility notes.
How do I implement GraphQL subscriptions in Laravel with this package?
Use `GraphQL\Server\StandardServer` with a subscription handler (e.g., `GraphQL\Server\SubscriptionHandler`). For real-time updates, integrate with Laravel Echo and Pusher/Redis. Subscriptions require a WebSocket server (e.g., `beyondcode/laravel-websockets`) and resolvers returning `GraphQL\Type\Definition\ResolveInfo` with async logic.
What’s the performance impact of using this package for complex GraphQL schemas?
Performance depends on schema depth and query complexity. Mitigate overhead by enabling persisted queries (`$server->setPersistedQueryLoader()`) and using query complexity analysis to block expensive queries. For large schemas, lazy-load types or split into modular schemas. Benchmark with tools like `k6` or Laravel Debugbar.
Can I use custom scalars (e.g., UUID, DateTime) in this package with Laravel?
Yes. Define custom scalars by extending `GraphQL\Type\ScalarType` and register them in your schema. For Laravel-specific types (e.g., `Carbon` instances), create a scalar that serializes/deserializes to/from PHP values. Example: `new GraphQL\Type\ScalarType(['name' => 'DateTime', 'serialize' => fn($value) => $value->format('Y-m-d')])`.
How do I test GraphQL endpoints in Laravel using this package?
Use `GraphQL\Test\TestCase` for PHPUnit or Pest tests. Mock resolvers and schema validation with `Schema::assertValid()`. Test subscriptions with Laravel’s HTTP tests and WebSocket clients. Example: `public function testQuery() { $query = 'query { user(id: 1) { name } }'; $result = $this->graphQL($query)->assertNoErrors()->getData(); }`.
Are there alternatives to webonyx/graphql-php for Laravel GraphQL?
Yes. Alternatives include `rebing/graphql-laravel` (Laravel-specific wrapper), `graphql-php/graphql-http` (for HTTP servers), or `overblog/graphql-bundle` (Symfony/Laravel). `webonyx/graphql-php` is the most spec-compliant but requires manual Laravel integration. Choose based on need: `rebing/graphql-laravel` offers tighter Laravel integration but lags in spec support.
How do I handle authentication in GraphQL resolvers with Laravel’s auth system?
Pass the authenticated user to resolvers via the `context` parameter. In your route, set the context: `$server->setContext(fn() => ['user' => Auth::user()])`. Access it in resolvers with `$context['user']`. For middleware-based auth, use Laravel’s `Authenticate` middleware and inject the user into the context.
What’s the migration path if I’m upgrading from v14.x to v15.x in Laravel?
v15.x introduced breaking changes (e.g., `RequestError` refactoring, PHP 7.4+ requirement). Update dependencies, refactor resolvers to use new error handling (e.g., `GraphQL\Error\Error`), and test subscriptions if used. Check the [upgrade guide](https://github.com/webonyx/graphql-php/blob/master/UPGRADE.md) for resolver and type changes. Laravel-specific integrations (e.g., middleware) may need adjustments.
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata