andi-lab / graphql-php
GraphQL library for PHP
1.0.1
2024-02-14 13:20 UTC
Requires
- php: ^8.1
- phpdocumentor/reflection-docblock: ^5.3
- spiral/attributes: ^3.1
- spiral/core: ^3.7
- webonyx/graphql-php: ^15.4
Requires (Dev)
- mockery/mockery: ^1.6
- phpunit/phpunit: ^10.2
- vimeo/psalm: ^5.17
This package is auto-updated.
Last update: 2024-12-19 12:45:44 UTC
README
GraphQL library
The GraphQL library for PHP allows you to define a GraphQL API using attributes, interfaces, and prepared abstract classes.
Features
Key features of the library include:
- framework agnostic, currently integrated with SpiralFramework on RoadRunner;
- support code first & schema first principles, which can simultaneously complement each other;
- extending via middleware layers.
Simple Example
use Andi\GraphQL\Attribute\Argument; use Andi\GraphQL\Attribute\MutationField; use Andi\GraphQL\Attribute\QueryField; final class SimpleController { #[QueryField(name: 'echo')] #[MutationField(name: 'echo')] public function echoMessage(#[Argument] string $message): string { return 'echo: ' . $message; } }
This example shows how easy it is to define Query & Mutation. At the same time, the library provides full control when defining a GraphQL schema: custom types, required fields, default values, and much more.
Documentation
Documentation is currently available in:
Examples
The library includes examples of defining a GraphQL schema. All definitions mentioned in the documentation are present in the examples in one form or another.
License
See LICENSE
Community
Telegram group: GraphQL library for PHP
Roadmap
- release 1.0
- documentation of the development of middleware layers, with an example
- documentation and example of connecting the
ecodev/graphql-upload
library for uploading files - support multiple schemas for
andi-lab/graphql-php-spiral
- release 1.1
- mockup types and fields
- other release
- inputs validate
- integration with Apollo Federation