- What is GraphQLite and how does it work with Laravel?
- GraphQLite is a framework-agnostic PHP library that uses attributes to declare a GraphQL schema and resolvers. In Laravel you install thecodingmachine/graphqlite-laravel, which provides the service provider, configuration publishing, and route registration. The core package sits between your application code and webonyx/graphql-php, translating attributes such as #[Type], #[Query], and #[Mutation] into an executable schema at runtime.
- How do I install GraphQLite in a Laravel application?
- Install the Laravel integration with composer require thecodingmachine/graphqlite-laravel, then publish its configuration and define the namespace or directory GraphQLite should scan for attribute-annotated classes. Register the GraphQL route through the integration so requests reach a /graphql endpoint. A small working endpoint is usually achievable in a short spike, but verify container autowiring and configuration against your Laravel version.
- Do I need to write GraphQL SDL schema files with GraphQLite?
- No. GraphQLite is code-first: you annotate PHP classes with attributes such as #[Type] and #[Field], and annotate controller methods with #[Query] or #[Mutation] to expose operations. The schema is generated from those attributes at runtime. If you ever need to leave the package, the generated output is a standard webonyx/graphql-php schema, so hand-written type definitions remain a viable escape hatch.
- Can GraphQLite use my existing Eloquent models and DTOs?
- GraphQLite is designed to reduce boilerplate by letting you annotate existing DTOs, service classes, and controller methods in place. Eloquent models can also be annotated in principle, but you should verify reflection behavior, relationship exposure, and input mapping during a spike. Treat the ability to expose models directly as something to test carefully rather than assuming every Eloquent detail maps cleanly to GraphQL.
- How does authorization and validation work in GraphQLite for Laravel?
- GraphQLite provides field-level authorization through the #[Security] attribute, and the Laravel integration should be verified alongside Laravel Gates and Policies. For input validation, the evaluation notes Laravel Validator rule support for #[Input]-based user input plus custom input validators added in v6.0.0. Confirm both authorization and validation behavior in your own spike because the Laravel documentation path is less detailed than the Symfony bundle documentation.
- Which Laravel and PHP versions does GraphQLite support?
- The core package has a PHP ^8.1 floor and is tested on PHP 8.2, with hard coupling to webonyx/graphql-php majors: v14.9 for GraphQLite 5.x and v15 from 6.2.0. Laravel support comes through the separate thecodingmachine/graphqlite-laravel package, so check that package's Composer constraints for your specific Laravel version. Do not assume the core package's constraints alone guarantee compatibility with your Laravel release.
- Is GraphQLite safe for production, and what protections do I need to add?
- GraphQLite is a schema generation accelerator, not a full GraphQL platform. It does not ship DataLoader batching, persisted queries, query cost analysis, or Apollo-compatible caching semantics out of the box, so you must build or buy those protections. Introspection disabling, maximum query complexity, and maximum query depth are documented more explicitly for the Symfony bundle, so independently confirm and configure the Laravel equivalents before production.
- How do I test a GraphQLite API in Laravel?
- Test resolvers and controllers as normal PHP units, then add integration tests that send GraphQL queries to your /graphql endpoint and assert the JSON response and errors. Because the schema is built through reflection, include tests that build the schema and run introspection so attribute or type mapping mistakes fail early. Laravel HTTP test helpers can drive the endpoint once the integration route and container wiring are configured.
- What are the alternatives to GraphQLite for Laravel?
- Lighthouse is the common schema-first alternative and uses .graphql SDL files rather than PHP attributes. You can also hand-wire webonyx/graphql-php type definitions yourself, which gives maximum control but much more boilerplate. GraphQLite's advantage is attribute-first schema generation with minimal SDL, while its tradeoffs include a smaller ecosystem and internals that are not especially Laravel-idiomatic.
- How actively maintained is GraphQLite, and what are the upgrade risks?
- GraphQLite has a relatively small ecosystem, around 578 stars in the evaluation, and release notes suggest a small maintainer group with single-maintainer concentration risk. The project has shipped breaking or behavior-changing items in minor releases, including file uploads becoming optional in v4.1.0, input semantics changing in v6.0.0, PSR-11 v2 requirements in v6.1.0, and enum naming changes in v4.0.2. Treat minor upgrades as potentially breaking, pin versions, and budget time for upgrade testing; MIT licensing and the standard webonyx schema output mitigate some long-term risk.