Nette Framework GraphQLite Extension
Usage
composer require maxa-ondrej/nette-graphql
Nette Framework Usage
config.neon
extensions:
graphql: Maxa\Ondrej\Nette\GraphQL\DI\GraphQLExtension
MyPresenter.php
<?php declare(strict_types=1);
namespace App\Presenters;
use TheCodingMachine\GraphQLite\Annotations\Query;
/**
* Class MyPresenter
*
* @package App\Presenters
*/
final class MyPresenter {
/**
* GraphQL request example:
* {
* echo(name: "World")
* }
* outputs -> "Hello World"
*/
#[Query]
public function echo(string $name): string {
return 'Hello '. $name;
}
}
Use the already predefined class attributes:
#[Authentication]
-> class must implementTheCodingMachine\GraphQLite\Security\AuthenticationServiceInterface
#[Authorization]
-> class must implementTheCodingMachine\GraphQLite\Security\AuthorizationServiceInterface
#[Middleware(Middleware::FIELD)]
-> class must implementTheCodingMachine\GraphQLite\Middlewares\FieldMiddlewareInterface
#[Middleware(Middleware::PARAMETER)]
-> class must implementTheCodingMachine\GraphQLite\Middlewares\ParameterMiddlewareInterface
Or use a custom implementation of Maxa\Ondrej\Nette\GraphQL\DI\SchemaFactoryDecoratorService
and add class attribute #[FactoryDecorator]
.
GraphQLite documentation