@Annotations
On the previous guide you saw how to map resolvers (callables) from a existing SDL (.graphql or .gql). Annotations enables the other way around, it provides a GraphQL SDL from annotated PHP code.
Last updated
On the previous guide you saw how to map resolvers (callables) from a existing SDL (.graphql or .gql). Annotations enables the other way around, it provides a GraphQL SDL from annotated PHP code.
Last updated
<?php declare(strict_types=1);
namespace App;
use GraphQL\Type\Definition\ResolveInfo;
use Siler\GraphQL\Annotation\Field;
use Siler\GraphQL\Annotation\ObjectType;
/** @ObjectType */
class Query
{
/** @Field(description="A common greet") */
public static function hello(): string
{
return 'Hello, World!';
}
}<?php declare(strict_types=1);
namespace App;
use function Siler\GraphQL\{annotated, init};
require_once __DIR__ . '/vendor/autoload.php';
$schema = annotated([Query::class]);
init($schema);type Query {
"""
A common greet
"""
hello: String!
}query {
hello
}{
"data": {
"hello": "Hello, World!"
}
}composer require doctrine/cacheSiler\GraphQL\Deannotator::cache(new ApcuCache());