The GraphQL library for PHP allows you to define a GraphQL API using attributes, interfaces, and prepared abstract classes.
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.
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 is currently available in:
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.
See LICENSE
Telegram group: GraphQL library for PHP
- 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