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 Php

Graphql Php Laravel Package

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.

View on GitHub
Deep Wiki
Context7

A PHP port of GraphQL reference implementation

Frequently asked questions about Graphql Php
How do I integrate webonyx/graphql-php into a Laravel application?
Install via Composer (`composer require webonyx/graphql-php`), then use Laravel-specific packages like `graphql-laravel` or `overblog/graphql-bundle` for routing, middleware, and schema management. These packages bridge GraphQL with Laravel’s service container and middleware stack.
Does this package support Laravel’s Eloquent ORM for database queries?
Yes, you can use Eloquent models in resolvers by injecting the database connection or repository services. For batching queries (to avoid N+1 issues), implement `DataFetcherInterface` or use `graphql-php-extensions` for DataLoader integration.
Can I use GraphQL with Laravel’s API Resources for serialization?
Not directly, but you can transform Eloquent models into GraphQL types by mapping fields in resolvers. For complex cases, use Laravel’s `ApiResource` logic inside resolvers or leverage `graphql-laravel`’s built-in support for Eloquent.
What Laravel versions are compatible with webonyx/graphql-php?
The package itself is framework-agnostic, but Laravel integrations (e.g., `graphql-laravel`) typically support Laravel 8.x and 9.x. Check the specific package’s docs for version constraints, as they may vary.
How do I handle authentication in GraphQL queries for Laravel?
Use Laravel’s built-in auth system by passing the `Auth` facade or `Request` object in the GraphQL execution context. For field-level permissions, create custom directives (e.g., `@auth`) that check Laravel’s `Gate` or `Policy` system.
Is GraphQL introspection safe to enable in production?
No, disable introspection in production to avoid exposing schema details. Use environment variables or middleware to toggle it. For development, enable it via `GraphQLServer::addType(new IntrospectionType())` or config files.
How do I test GraphQL queries in Laravel’s PHPUnit?
Use Laravel’s `Http` facade with `GraphQL::query()` or mock the schema and execution context. For complex tests, leverage `graphql-laravel`’s testing helpers or create custom test cases that validate resolver outputs against expected GraphQL responses.
What’s the best way to optimize resolver performance in Laravel?
Use async resolvers with `ReactPHP` or `Amp` for non-blocking I/O, and implement batching via `DataLoader` (from `graphql-php-extensions`) to reduce database queries. Avoid synchronous DB calls in resolvers for high-traffic endpoints.
Can I use GraphQL subscriptions with Laravel and webonyx/graphql-php?
Yes, but you’ll need additional tooling like `graphql-php-extensions` for WebSocket support. Integrate with Laravel’s `Broadcast` system or use third-party packages like `laravel-websockets` to handle real-time subscriptions.
What are the alternatives to webonyx/graphql-php for Laravel?
Consider `overblog/graphql-bundle` (Symfony/Laravel bundle) or `graphql-php/graphql-http` for HTTP server integration. For simpler needs, Laravel’s `ApiResource` with REST may suffice, but GraphQL offers better flexibility for client-driven queries.
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope