Download the PHP package reydajp/cake-graphql without Composer
On this page you can find all versions of the php package reydajp/cake-graphql. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download reydajp/cake-graphql
More information about reydajp/cake-graphql
Files in reydajp/cake-graphql
Package cake-graphql
Short Description GraphQL endpoint plugin for CakePHP 5 using GraphQLite and Webonyx GraphQL PHP.
License MIT
Informations about the package cake-graphql
CakeGraphQL - GraphQL plugin for CakePHP 5
CakeGraphQL is a CakePHP 5 plugin for GraphQL endpoint routing, endpoint-level authentication, engine selection, and GraphQLite integration.
The plugin owns the HTTP endpoint and GraphQL engine wiring. The host application owns resolver classes, entity/type annotations, authentication provider setup, field-level authorization, and business logic.
Requirements
- PHP 8.3 or newer
- CakePHP 5
- GraphQLite 8
- Webonyx GraphQL PHP 15
Installation
Load the plugin in the host application:
Configuration
Configure the plugin with the Graphql key:
The plugin registers the configured route and attaches route-specific GraphQL middleware. CakePHP routing middleware must run as usual in the host application. maxDepth and maxComplexity reject overly nested or expensive GraphQL operations before resolver execution.
See docs/configuration.md for the full configuration contract.
Resolver Example
Register resolver classes explicitly in Graphql.engines.Graphqlite.queries. CakeGraphQL does not scan broad application namespaces by default.
See docs/graphqlite.md for CakePHP examples using GraphQLite #[Query], #[Type], and #[Field] attributes.
Error Responses
CakeGraphQL returns normal GraphQL partial responses for resolver and field errors after execution starts: HTTP 200, partial data, and an errors entry with the field path. Cake HTTP exceptions thrown by resolvers expose their client-safe message, for example User not found.
Endpoint-level authentication still happens before GraphQL execution. When authenticated is true and the request has no Cake identity, the endpoint returns HTTP 401. Resolver-level authentication errors from GraphQLite attributes such as #[Logged] are GraphQL execution errors and return HTTP 200.
Bake Command
Generate a collection query resolver:
Generate a single-record query resolver:
Generate into a custom namespace:
By default, the command updates Graphql.engines.Graphqlite.queries in config/app_local.php or config/app.php. Use --no-config to skip that update.
See docs/bake.md for details.
Authentication
When authenticated is true, CakeGraphQL rejects requests before GraphQL execution if the request has no identity attribute. This relies on the host application's Cake Authentication middleware running before the GraphQL route middleware.
CakeGraphQL bridges Cake Authentication's request identity into GraphQLite's authentication service. GraphQLite resolvers can inject the current Cake user with #[InjectUser]:
If the injected parameter is not nullable, GraphQLite requires a logged-in user for that field. #[Logged] also uses the bridged Cake identity.
The bridge reads Cake's request identity attribute. AuthenticationComponent remains controller-only and is not available inside resolver classes.
Field-level authorization is intentionally engine-specific. GraphQLite attributes such as #[Right] or #[Security] require GraphQLite authorization services; CakeGraphQL does not currently bridge Cake Authorization into those services.
See docs/graphqlite.md for examples and the current integration boundary.
Commands
License
MIT. See LICENSE.
All versions of cake-graphql with dependencies
cakephp/cakephp Version ^5.0
thecodingmachine/graphqlite Version ^8.3
webonyx/graphql-php Version ^15.32