webonyx/graphql-php
webonyx/graphql-php is a GraphQL server implementation for PHP, following the official GraphQL specification and modeled after graphql-js. Build schemas, execute queries, validate documents, and extend via types, resolvers, and tooling for production APIs.
laravel-graphql or custom integrations).GraphQL\Server\Middleware).Route::graphql()) or API resource controllers.GraphQL\Executor\Promise\Adapter\SyncPromise).graphql-codegen can auto-generate Laravel/Eloquent resolvers).overrideStandardTypes()) may require refactoring if using older patterns.GraphQL\Validator\QueryComplexity).Laravel\Promises or ReactPHP).@auth) integrate with Laravel’s gates/policies?graphql-php/server or custom middleware).graphql-inspector) fit into Laravel’s CI/CD?GraphQL\Server\Subscription) be needed? (Requires Laravel + Pusher/Redis).overblog/graphql-bundle) that better fit Laravel’s ecosystem?GraphQLServiceProvider (registering schema, middleware, and routes).GraphQL\Type\Definition\Type and GraphQL\Executor\ExecutionResult as Laravel services.GraphQL\Event\QueryExecuted for post-query logic (e.g., logging, analytics).Route::prefix('graphql')->group(function () {
Route::post('/', [GraphQLController::class, 'query']);
Route::post('/subscription', [GraphQLController::class, 'subscribe']);
});
GraphQL\Server\Middleware\Middleware for CORS, auth, or rate limiting.GraphQL\Type\Definition\ResolveInfo to map fields to Eloquent queries.DB::select() in resolvers (with proper error handling)..graphql files (using graphql-php/schema).graphql-codegen or manual mapping.GraphQLServiceProvider:
$schema = new Schema([
'query' => new Query(),
'mutation' => new Mutation(),
'subscription' => new Subscription(),
]);
GraphQL\Validator\QueryComplexity).overblog/graphql-bundle (if using Symfony-like structure).react/promise or amp/amp for async support.graphql-php/server or a custom Laravel middleware.User queries) to validate the setup.@auth).SchemaExtender for runtime schema modifications.webonyx/graphql-php for security patches (e.g., DoS fixes).composer.json to avoid breaking changes.docs/ folder).GraphQL\Error\Debug for detailed error messages in development.Log facade.GraphQL\Validator\QueryComplexity).throttle middleware).pdo_pgsql for PostgreSQL).GraphQL\Executor\Promise\Adapter\AmpFutureAdapter for async I/O.| Failure Scenario | Mitigation Strategy |
|---|---|
| Schema Validation Errors | Use Schema::assertValid() in tests; provide clear error messages. |
| DoS via Complex Queries | Enforce QueryComplexity limits; use GraphQL\Validator\Rule\QueryDepth. |
| Resolver Timeouts | Set PHP max_execution_time; use async resolvers for slow operations. |
How can I help you explore Laravel packages today?