- How do I install rebing/graphql-laravel in a Laravel application?
- Install the package with Composer using composer require rebing/graphql-laravel, then publish its configuration file so you can define schemas and endpoints. Laravel auto-discovers the service provider, which registers the GraphQL controller. After publishing config/graphql.php, you can generate starter types, queries, and mutations with the package's Artisan commands.
- What Laravel and PHP versions does rebing/graphql-laravel support?
- The package requires PHP ^8.2, Laravel 12.x through 13.x, and webonyx/graphql-php ^15.22.1. That is a narrow support band with no LTS backport path, so applications on Laravel 10 or 11 must upgrade the framework before or alongside adoption. Treat this as a platform upgrade decision, not just a library install.
- How do I create a GraphQL query or mutation with rebing/graphql-laravel?
- Use the bundled Artisan generators such as make:graphql:query, make:graphql:mutation, and make:graphql:type to scaffold PHP classes. Queries and mutations extend the package's Support\Field class, while types extend Support\Type. Register the generated classes in config/graphql.php or in a ConfigConvertible schema class.
- Can rebing/graphql-laravel handle multiple GraphQL schemas in one Laravel app?
- Yes. The package supports multiple schemas, each with its own queries, mutations, and types. Each schema can also have its own HTTP middleware and GraphQL execution middleware. This is useful when you need a public API schema alongside an internal backend-for-frontend schema.
- Does rebing/graphql-laravel support GraphQL subscriptions?
- No. The package does not support GraphQL subscriptions, and its README explicitly defers real-time functionality to solutions like Lighthouse or custom broadcasting. If live updates are on your roadmap, treat subscriptions as a separate workstream. You can still use this package for queries and mutations while implementing subscriptions elsewhere.
- How do I avoid N+1 queries with rebing/graphql-laravel?
- The package offers two data-loading strategies. Dataloaders use webonyx/graphql-php's deferred resolution to batch field loads from any data source. The optional SelectFields package, maintained in a separate repository, analyzes GraphQL selections and generates optimized Eloquent select() and eager-loaded with() calls. Because SelectFields is a sidecar dependency, verify its maintenance cadence for your expected service lifetime.
- How do I test GraphQL endpoints built with rebing/graphql-laravel?
- The package includes Laravel-friendly testing helpers, including httpGraphql() for exercising GraphQL requests in feature tests. It also provides SqlAssertionTrait for asserting SQL query counts, which helps catch N+1 regressions. These helpers shorten the time to first endpoint test and fit naturally into Laravel's existing test suite.
- What middleware options does rebing/graphql-laravel provide?
- It has a two-layer middleware model. Execution middleware wraps the whole GraphQL operation, while resolver middleware wraps individual fields. You can also assign per-schema HTTP middleware and per-schema execution middleware, which gives clean seams for authentication context injection, persisted queries, query cost accounting, and tracing.
- Is rebing/graphql-laravel a good alternative to Lighthouse for Laravel?
- rebing/graphql-laravel is code-first: you define queries, mutations, and types in PHP classes rather than SDL files. Lighthouse is SDL-first and supports subscriptions, so it is the better fit if real-time push is required. Choose rebing when your team prefers PHP classes, Eloquent integration, and Laravel-native validation and authorization without a real-time requirement.
- Is rebing/graphql-laravel production-ready and actively maintained?
- The package includes production-relevant controls such as introspection disabled by default, depth and complexity limits, batching limits, and GET read-only enforcement. However, you should verify maintainer count, bus factor, and provenance rather than relying on stars, especially given metadata showing zero dependents and an unusually far-future last-release date. It also has no evidence of Apollo Federation or subgraph support, which matters if your organization standardizes on a federated graph.