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

webonyx/graphql-php

A PHP implementation of the GraphQL specification, based on the JavaScript reference implementation. It's fully compliant with the October 2021 spec, with September 2025 compliance in progress, and supports schema building, query execution, and validation.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • API Modernization: Adopt GraphQL as a replacement for REST or gRPC to enable flexible, client-driven data fetching and reduce over-fetching/under-fetching. This package provides a production-ready PHP implementation aligned with the latest GraphQL spec (October 2021, with September 2025 in progress), ensuring long-term compatibility with tools like Apollo, Relay, and GraphiQL.
  • Microservices & Federation: Enable GraphQL Federation (via Apollo Federation or similar) to compose data from multiple services into a unified schema. The package's schema stitching and persisted queries capabilities support scalable architectures.
  • Query Normalization & Payload Efficiency: Printer::stripIgnoredCharacters() (v15.38.0) produces a canonical, minified document by removing characters that don't change meaning. This directly supports persisted-query keying, query-cache normalization, and on-the-wire payload reduction — the infrastructure behind CDN cache hit rates and APQ (automatic persisted queries) implementations.
  • Request Batching & Error Semantics: v15.38.1 fixes batch request handling so malformed scalar batch entries (e.g. ["x"], {"query":"{ a }","0":"x"}) raise a RequestError rather than a TypeError. Product impact: batched requests now fail as client errors with spec-shaped GraphQL error responses instead of surfacing as generic server faults. This matters if we expose batching (common with Apollo links / mobile clients) — it keeps error classification, HTTP status mapping, and client retry logic correct, and prevents malformed client payloads from polluting 5xx error budgets and alerting.
  • Hardening & Compliance: v15.38.0 rejects invalid UTF-8 in incoming documents at the parser boundary; v15.38.1 tightens request-coercion error typing. Together these close parser-level and transport-level robustness gaps — relevant if we expose a public endpoint or operate in a regulated/audited environment, and useful evidence of a maintained, security-conscious dependency for vendor review.
  • Developer Experience (DX): Accelerate frontend-backend alignment by allowing frontend teams to define schemas in GraphQL SDL, reducing API versioning friction. The package includes introspection, validation, and autogenerated docs (via SchemaPrinter). Correct RequestError types also mean frontend clients receive actionable, structured errors instead of opaque failures.
  • Build vs. Buy:
    • Buy: If the team lacks GraphQL expertise or needs rapid implementation (this package is battle-tested with 4.7K stars and MIT license).
    • Build: Only if requiring cutting-edge features (e.g., experimental GraphQL 2025 specs) or custom optimizations (e.g., unique query planning logic).
  • Use Cases:
    • Public APIs: Serve GraphQL endpoints for third-party consumers (e.g., mobile apps, dashboards).
    • Internal Tools: Power admin panels or analytics tools with dynamic queries.
    • Legacy System Integration: Gradually migrate REST APIs by wrapping them in GraphQL resolvers.

When to Consider This Package

Adopt This Package If:

  • Your stack is PHP/Laravel and you need a mature, spec-compliant GraphQL implementation.
  • You prioritize performance (optimized query planning, reduced recursion, native PHP types in v15+, query minification/normalization via stripIgnoredCharacters()).
  • Your team requires strong typing, validation, introspection, and input hardening (invalid UTF-8 rejection, correct RequestError typing for malformed/batched requests) out of the box.
  • You're using Laravel and want seamless integration (e.g., middleware, caching, or Eloquent resolvers via graphql-php-laravel).
  • You need persisted queries (reduces payload size and improves security) — stripIgnoredCharacters() is the natural primitive for stable document hashing and cache keys.
  • You plan to support request batching from Apollo/mobile clients and need predictable client-vs-server error classification.
  • Your frontend uses Apollo Client, Relay, or GraphiQL (this package is their reference implementation).

Look Elsewhere If:

  • You need GraphQL 2025 features (only partially supported; track #1931).
  • Your team requires real-time subscriptions (consider graphql-php-subscriptions or WebSockets).
  • You're using PHP 7.3 or lower (requires 7.4+).
  • You need GraphQL Mesh or Apollo Federation (this is a core library; use with federation tools).
  • Your use case demands ultra-low latency (e.g., gaming); benchmark against alternatives like GraphQL Ruby or Hasura.
  • You prefer TypeScript/JavaScript for backend GraphQL (e.g., Apollo Server).

How to Pitch It (Stakeholders)

For Executives:

*"This is the de facto standard for PHP GraphQL, used by teams at companies like Shopify, GitLab, and Segment. By adopting graphql-php, we:

  • Future-proof our APIs: Align with the GraphQL ecosystem (Apollo, Relay) to reduce frontend-backend friction.
  • Cut development time: Leverage 4.7K+ stars, MIT license, and Laravel integration to ship faster.
  • Improve scalability: Persisted queries, query normalization (stripIgnoredCharacters()), and query planning optimize performance for high-traffic APIs and improve cache hit rates.
  • Reduce risk: Recent releases actively harden the parser (invalid UTF-8 rejection) and correct error typing for batched/malformed requests (v15.38.1) — a sign of a maintained, security-conscious dependency.
  • Enable composable architectures: Support microservices and federation for modular growth. Investment: Low (open-source, maintained by a solo dev with sponsorships). ROI: Faster feature delivery, happier devs, and future-proof tech."*

For Engineering:

*"This is the most stable, performant PHP GraphQL library, with:

  • Full spec compliance (October 2021, partial 2025).
  • Laravel-friendly: Works with Eloquent, middleware, and caching.
  • Developer ergonomics:
    • Introspection for tooling (GraphiQL, Postman).
    • Validation to catch schema errors early.
    • Persisted queries for security/performance.
    • Printer::stripIgnoredCharacters() (v15.38.0) for canonical, minified documents — use it to derive stable persisted-query hashes and shrink payloads.
    • Invalid UTF-8 rejection (v15.38.0) at the document boundary.
    • Correct request error typing (v15.38.1): malformed scalar batch entries now raise RequestError instead of TypeError, so batched clients get proper GraphQL error responses rather than 5xx-class faults.
  • Optimized for scale: Query planning, reduced recursion, native PHP types, and normalized documents. Trade-offs:
  • No built-in subscriptions (add graphql-php-subscriptions).
  • PHP 7.4+ required. Next steps:
  1. Spike: Benchmark against REST/gRPC for a sample query; verify stripIgnoredCharacters() output is stable across our schema/printers before keying a cache on it.
  2. Integrate: Use graphql-php-laravel for Laravel.
  3. Adopt incrementally: Start with a single service or public API.
  4. Upgrade: v15.32.3 → v15.38.1 is a low-risk patch/minor line; no breaking changes. Watch one behavior shift: if we currently catch TypeError around batched request coercion, update those handlers to catch RequestError (and confirm error formatters/HTTP mapping emit 4xx for batch coercion failures)."*

For Frontend Teams:

*"This backend uses the same GraphQL spec as Apollo Client/Relay, so:

  • No API versioning headaches: Frontend defines the schema; backend adheres to it.
  • Efficient data fetching: Query exactly what you need (no over-fetching), with persisted queries shrinking request payloads.
  • Better batch error handling: Malformed batched entries now return structured GraphQL errors instead of opaque server errors — your BatchLink error handling will behave predictably.
  • Tooling support: Works with GraphiQL, Apollo Studio, and VS Code GraphQL extensions. Ask backend:
  • Can we get a GraphQL Playground endpoint for exploration?
  • Will you support persisted queries to reduce payload size?
  • Is request batching enabled, and are batch errors mapped to 4xx?"*
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.
ably/pubsub-server
mstfkhazaal/defender
mfonte/base62x
karnoweb/metapilot
tobya/bcsapiwrapper
swalker2/cpanel
vish4395/laravel-translation-manager
morningtrain/economic
teksite/systeminfo-laravel
atomcms/voting
run6/weather
siokas/laravelembeddirectives
adamlien/pkuuids
gilsonsouza/lara-doc-generator
manelgavalda/enrollment_mobile
unabomber/timezone
delatbabel/contacts
astritzeqiri/g-recaptcha
kevinongko/laravel-genode
developeruz/laravel-analytics