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 Laravel Laravel Package

rebing/graphql-laravel

Code-first GraphQL integration for Laravel based on webonyx/graphql-php. Define schemas, types, queries and mutations in PHP. Supports multiple schemas, per-schema middleware, resolver middleware, and n+1 prevention via dataloaders or SelectFields eager loading.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

Build vs. Buy Decision

  • Build: If your team requires custom GraphQL features (e.g., real-time subscriptions, advanced caching, or proprietary query optimization), this package provides a foundational layer to extend rather than starting from scratch. The code-first schema definition (PHP classes) aligns with Laravel’s conventions, reducing learning curves for backend teams.
  • Buy: If you need out-of-the-box subscriptions or a managed GraphQL service, consider alternatives like Lighthouse (supports subscriptions) or Hasura (serverless). However, for Laravel-native, REST-like flexibility, this package is a high-leverage buy.

Feature Roadmap Enablement

  • API Modernization:
    • Replace REST endpoints with GraphQL to enable client-driven data fetching, reducing over-fetching/under-fetching.
    • Example: Migrate a legacy /users/{id} endpoint to a user(id: ID!): User query with nested fields (e.g., user { id name posts { title } }).
  • Microservices & Aggregation:
    • Use multiple schemas to isolate APIs (e.g., admin, public, partner) with schema-specific middleware (e.g., rate limiting, auth).
    • Example: A partner schema could expose partnerOrders with custom validation for B2B clients.
  • Performance Optimization:
    • Dataloaders (batch loading) and SelectFields (Eloquent optimization) reduce N+1 queries without manual query writing.
    • Example: Replace User::with('posts')->find($id) with a UserType using SelectFields to auto-optimize select() and with() calls.
  • Validation & Security:
    • Laravel validation rules can be applied to GraphQL arguments (e.g., email: 'required|email'), reducing duplication with REST controllers.
    • Privacy settings (e.g., @private) enforce field-level access control (e.g., hide user.salary for non-admins).
  • Developer Experience (DX):
    • Artisan generators (e.g., make:graphql:query) accelerate onboarding for backend teams unfamiliar with GraphQL.
    • GraphiQL IDE (optional) provides a self-service API explorer for frontend teams.

Use Cases

Use Case How This Package Helps
Headless CMS Expose content models (e.g., Article, Category) with nested queries (e.g., article { title author { name } }).
Mobile Apps Reduce payload size with client-controlled field selection (e.g., fetch only user.id and user.name for login).
Multi-Tenant SaaS Use schema isolation to expose tenant-specific APIs (e.g., tenant1.graphql, tenant2.graphql).
Legacy System Integration Wrap legacy REST APIs as GraphQL "wrappers" (e.g., a legacyUser(id: ID!): User query that proxies to a SOAP service).
Internal Tools Build admin dashboards with complex queries (e.g., reports { metrics { users active } }) without bloating REST endpoints.

When to Consider This Package

Adopt This Package If:

✅ You’re using Laravel 12/13 and want a native PHP-based GraphQL solution (no .graphql files). ✅ Your team prefers code-first schema definitions (aligns with Laravel’s Eloquent/Service Container). ✅ You need multiple schemas with schema-specific middleware (e.g., auth, rate limiting). ✅ Performance is critical, and you want Dataloaders or SelectFields to optimize Eloquent queries. ✅ You want deep Laravel integration (e.g., validation, auth, testing helpers). ✅ Subscriptions are not required (use Lighthouse or Laravel Echo for real-time features).

Look Elsewhere If:

❌ You need GraphQL subscriptions (this package does not support them; use Lighthouse instead). ❌ Your team prefers schema-first GraphQL (e.g., .graphql files) over PHP classes. ❌ You’re using Laravel <12 (requires PHP 8.2+). ❌ You need a managed GraphQL service (consider Hasura or AWS AppSync). ❌ You’re building a public API with strict query depth/complexity limits (this package requires manual configuration).


How to Pitch It (Stakeholders)

For Executives (Business Leaders)

"We’re modernizing our API to give our clients and internal teams faster, more flexible data access—without overhauling our backend. This Laravel GraphQL package lets us:

  • Reduce API complexity: Clients fetch only the data they need (e.g., a mobile app requests user.id and user.name instead of full user objects).
  • Accelerate development: Backend teams use familiar Laravel tools (Eloquent, validation) to define GraphQL schemas in PHP.
  • Support multi-tenant SaaS: Isolate APIs for partners/admins with schema-specific permissions.
  • Cut costs: Avoid over-fetching data (e.g., no more bloated REST responses with unused fields). It’s a low-risk upgrade—we can phase it in alongside REST APIs and see 20–30% faster payloads in testing."

Ask:

  • "Which teams would benefit most from self-service data access (e.g., frontend, mobile, internal tools)?"
  • "Are there legacy APIs we can modernize first as a proof of concept?"

For Engineering Leaders (Tech Leads/Architects)

"This package gives us a production-ready GraphQL layer for Laravel with key advantages:

  • Performance: Dataloaders and SelectFields optimize Eloquent queries automatically—no manual with() or batching code.
  • Security: Field-level privacy, validation, and schema isolation reduce attack surface.
  • Developer Velocity: Artisan generators (e.g., make:graphql:query) and Laravel validation integrate seamlessly with existing workflows.
  • Future-Proof: Supports multiple schemas, custom middleware, and observability (OpenTelemetry).

Compared to alternatives:

  • Lighthouse: Better for subscriptions but heavier.
  • REST: Can’t compete with client-driven data fetching.
  • Hasura: Overkill for Laravel; this is native and lightweight."

Ask:

  • "Should we start with a single schema (e.g., public) or multiple schemas (e.g., admin, partner)?"
  • "Which performance bottlenecks (e.g., N+1 queries) can we target first?"
  • "Do we need GraphiQL for frontend teams, or is Postman sufficient?"

For Backend Teams (Developers)

"This package lets you build GraphQL APIs in Laravel—without learning a new language. Here’s how it works:

  1. Define schemas in PHP: Use make:graphql:type, make:graphql:query, etc., to scaffold classes.
    // Example: app/GraphQL/Types/UserType.php
    class UserType extends GraphQLType {
        public function fields() {
            return [
                'id' => Type::nonNull(Type::id()),
                'name' => Type::string(),
                'posts' => [
                    'type' => Type::listOf(PostType::class),
                    'resolve' => fn($user) => $user->posts,
                ],
            ];
        }
    }
    
  2. Leverage Laravel features:
    • Validation: Add rules to query args (e.g., email: 'required|email').
    • Auth: Use middleware to restrict fields (e.g., hide salary for non-admins).
    • Testing: Built-in helpers like httpGraphql() for PHPUnit.
  3. Optimize performance:
    • SelectFields: Auto-generates select() and with() for Eloquent.
    • Dataloaders: Batch database calls to avoid N+1.

No .graphql files—just PHP classes you already know. Start with a single query and expand as needed."

Ask:

  • "Which existing REST endpoints should we convert to GraphQL first?"
  • "Do we need custom scalars (e.g., for dates, JSON) or input types?"
  • "Should we enable GraphiQL for frontend teams to explore the API?"
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation